结构体使用

结构体中在有构造函数时不能有get;set;自动属性,2:不能有无参构造函数,

 1         public struct MyStruct
 2         {
 3             public MyStruct(string a, int b, double c)
 4             {
 5                 this.a = a;
 6                 this.b = b;
 7                 this.c = c;
 8             }
 9             public string a;
10             public int b;
11             public double c;
12         }
13 
14     public ActionResult Index()
15         {
16             List<MyStruct> lis = new List<MyStruct>();
17             MyStruct m1 = new MyStruct();
18             m1.a = "a";
19             m1.b = 1;
20             m1.c = 3.33;
21             lis.Add(m1);
22             lis.Add(new MyStruct("a", 2, 3.33));
23             return View();
24         }

 

posted @ 2015-06-18 16:00  若云  阅读(107)  评论(0)    收藏  举报