using System; //System最基本的引用 using System.Collections.Generic; using System.Text; namespace Welcome //命名空间 { class Welcome //类名,C#对大小写是敏感的 { //1、值类型 //1)、简单类型(Simples types) //1.1整数类型 public static short x = 100; //1.2布尔类型 public static bool b = true; //*只能写成True和False不能为1和0代替 //1.3字符类型 public static char c = 'A'; //*引处是单引号 //1.4实数类型 public static float f = 1; public static double d = 1; //2)、结构类型(Struct types) //结构体 struct PhoneBook{ public string Name; public uint Age; //未对其赋值,将一直保持默认类型 public string Phone; public string Address; } PhoneBook pb1; //结构体--结构体嵌套 struct PhoneBookExt{ public string Name; public uint Age; public string Phone; struct Address{ public string City; public string Street; public uint No; } } //3)、枚举类型 enum WeekDay { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday } static void Main(string[] args) //C#执行是从Main函数开始,但必须注意:Main函数一定要包含在类中 { //简单类型输出 Console.WriteLine("短整形x的值是:"+x); Console.WriteLine("布尔类型b的值是:" + b); Console.WriteLine("字符类型c的值是:" + c); //结构体类型输出 PhoneBook pb2; pb2.Name = "hehf"; pb2.Address = "NiQiu Town Taihe AnHui Province"; PhoneBookExt pb3; pb3.Name = "hehfExt"; Console.WriteLine("PhoneBook:" + pb2.Name + "/" + pb2.Address); Console.WriteLine("PhoneBookExt:" + pb3.Name); Console.ReadLine(); //回车后退出 } } }