日期:2014-05-20  浏览次数:20910 次

.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