日期:2014-05-17 浏览次数:20923 次
namespace T2TEST
{
public struct Test02
{
//私有字段_a
private int _a;
//私有字段_a的属性A
public int A
{
get { return _a; }
set { _a = value; }
}
//私有字段_b
private double _b;
//私有字段_b的属性B
public double B
{
get { return _b; }
set { _b = value; }
}
//输出_a,_b
public void Show()
{
Console.WriteLine("_a={0},_b={1}",_a,_b);
}
}
}
namespace T2TEST
{
class Program
{
static void Main(string[] args)
{
//创建结构体对象
Test02 te;
//通过属性赋值
te.A = 12;
te.B = 13.5;
te.Show();
}
}
}