读书人

.net vs2010中筑的一个控制台应用程序

发布时间: 2013-01-01 14:04:18 作者: rapoo

.net vs2010中建的一个控制台应用程序
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 类1
{
class Program
{
static void Main(string[] args)
{
Person p1 = new Person();
p1.name = "tom";
p1.age = 50;
p1.height = 100;
p1.SayHello();
Console.ReadKey();
}
}
class Person
{
public int height;
public int age;
public string name;
public void SayHello()
{
Console.WriteLine("大家好!我的名字是(0),我的年龄是(1),我的身高是(2)",this.name,this.age,this.height); );
}
}
}
以上我是照视频敲的
我运的结果和视频中结果不一样,请问各位最后一行 ("大家好!我的名字是(0),我的年龄是(1),我的身高是(2)",this.name,this.age,this.height)中(0),(1),(2)是什么意思,
[解决办法]
Console.WriteLine("大家好!我的名字是{0},我的年龄是{1},我的身高是{2}",this.name,this.age,this.height);
占位符
[解决办法]
应该是大括号而不是小括号
Console.WriteLine("大家好!我的名字是{0},我的年龄是{1},我的身高是{2}",this.name,this.age,this.height); );

参考msdn

建议读英文版
http://msdn.microsoft.com/en-us/library/txafckwd.aspx

如果实在不行,读中文版
http://msdn.microsoft.com/zh-cn/library/txafckwd.aspx

读书人网 >.NET

热点推荐