可以像这样使用结构体作为
string.Format
的参数吗?struct kid
{
public string name;
public int age;
};
kid.name = alice;
kid.age = 2;
Console.WriteLine(String.Format("Her name is {0} and she's {1} years old", kid));
改为这样:
Console.WriteLine(String.Format("Her name is {0} and she's {1} years old", kid.name ,kid.age));
编辑:
这个字符串将在运行时从配置文件中读取
ToString()
吗? - John Alexiou