tostring 的区别

cstt60777 2007-10-01 12:02:49
static void Main(string[] args)
{

int a = 33;
Console.WriteLine("a is:" + a);
}
和static void Main(string[] args)
{

int a = 33;
Console.WriteLine("a is:{0}",a);
}
区别在那??
...全文
61 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
cstt60777 2007-10-01
  • 打赏
  • 举报
回复
你的意思是说 Console.WriteLine("a is:" + a);
实际是 Console.WriteLine("a is:" + a.tostring());
吗??

Console.WriteLine("a is:" + a); 调用的是Console.WriteLine (String)原型
那么 Console.WriteLine("a is:{0}",a); 调用的是那个原型???
bitsbird 2007-10-01
  • 打赏
  • 举报
回复
重载
ezhuyin 2007-10-01
  • 打赏
  • 举报
回复
刚才好像回答不对题...

Console.WriteLine("a is:" + a); // 原型是Console.WriteLine(String)

Console.WriteLine("a is:{0}",a); // 原型是Console.WriteLine(String, Object)

这里属于重载范畴。
lalac 2007-10-01
  • 打赏
  • 举报
回复
==> Console.WriteLine("a is:{0}",a); 调用的是那个原型???

调用的是:
public static void Write(string format, object arg0)
{
//...
}
ezhuyin 2007-10-01
  • 打赏
  • 举报
回复
{0}

是字符串格式化

110,535

社区成员

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

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

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