类型如何转换

xmmandy 2009-04-25 10:22:55
c# winform下:
if (_score >= 10000 * nLevel)
{
nLevel++;//关数加1
timeSpan -= 80; //速度减80
StringFormat drawFormat = new StringFormat();
drawFormat.Alignment = StringAlignment.Center;
gpRun.DrawString("第 "+nLevel.ToString()+" 关",
new Font("Arial Black", 25f,FontStyle.Bold),
new SolidBrush(Color.White),
new RectangleF(0, _height * rectPix / 2 - 100, _width * rectPix, 100),
drawFormat);
drawFormat.Dispose();
timerBlock.Enabled = false;
Thread.Sleep(2000);
timerBlock.Enabled = true;
if (IsEnd)
{
FrmTetris ft = new FrmTetris();
FrmTetris f = new FrmTetris();
f.U = _score.ToString;
}

错误提示:错误 1 无法将方法组“ToString”转换为非委托类型“string”。您是要调用方法吗? G:\bishe\Tetris2\Tetris2\Palette.cs 283 31 Tetris2

...全文
89 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
烈火蜓蜻 2009-04-25
  • 打赏
  • 举报
回复
_score.ToString
改成
_score.ToString()
聖少俊 2009-04-25
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 xuezhanliang6886 的回复:]
.tostring()这是方法
强制转换用CONVERT.tostring
[/Quote]
学习
xuezhanliang6886 2009-04-25
  • 打赏
  • 举报
回复
.tostring()这是方法
强制转换用CONVERT.tostring
xmmandy 2009-04-25
  • 打赏
  • 举报
回复
谢谢大家
bagegejin 2009-04-25
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 gxtiou 的回复:]
f.U = _score.ToString;
改为 f.U = _score.ToString();
[/Quote]

正解,ToString是方法,不是属性
gxtiou 2009-04-25
  • 打赏
  • 举报
回复
f.U = _score.ToString;
改为 f.U = _score.ToString();

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧