枚举类型和 struct类型

C#的四种访问修饰符:
public
private
internal
protected:只有继承他的才能访问、

 

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 
 6 namespace Test
 7 {
 8     //enum枚举类型
 9     enum days {Monday=1 ,Tuesday ,Wenesday, Thursday, Friday, Saturday ,Sunday };
10     //强制转换为byte字节
11     //enum days :byte { Monday = 1, Tuesday, Wenesday, Thursday, Friday, Saturday, Sunday };
12     class Program
13     {
14         /// <summary>
15         /// 
16         /// </summary>
17         /// <param name="args"></param>
18         static void Main(string[] args)
19         {
20             int intValue = 1;
21             int intValue2 = new int();
22 
23             bool a = true; //System.bool
24             Boolean b = true; //System.Boolean
25             Console.WriteLine("{0},{1}",a, b); //输出a,b
26 
27             Person person = new Person();
28             person.age = 10;
29             Console.WriteLine(person.age);
30 
31             var c = days.Monday;
32             Console.WriteLine((int) c);   //输出c并强制转换为int类型
33             //Console.WriteLine(days.Monday);
34             Console.Read();
35 
36   
37         }
38 
39         //struct类型:是来用打包和封装一个小的数据集
40         struct Person
41             {
42                 public int age;
43                 public string name;
44                 public string name1;
45 
46             }
47     }
48 }

 

posted @ 2017-09-07 21:58  淡淡的烦恼  阅读(346)  评论(0编辑  收藏  举报