public struct Person
{
string Name;
int height;
int weight
public bool overWeight()
{
//implement something
}
}
结构中有string,怎么还说是值类型呢?
{
string Name;
int height;
int weight
public bool overWeight()
{
//implement something
}
}
结构中有string,怎么还说是值类型呢?
将struct修改成class
---------------------------------
http://www.cftea.com/c/2008/03/JHB3MJM8DYGS0JJ9.asp 在这个网页看到的:
类与结构的差别值类型与引用类型结构结构是值类型,值类型在堆栈上分配地址,所有的基类型都是结构类型,例如:int 对应System.int32 结构,string 对应 system.string 结构 ,通过使用结构可以创建更多的值类型。
---------这个意思是说在结构中string会分配在堆栈中吗