2013年2月23日

C#: 枚举

摘要: 枚举是用户定义的整数类型。在声明一个枚举时,要指定该枚举可以包含的一组可接受的实例值。using System;namespace ConsoleApplication3{classProgram{staticvoid Main(string[] args){WriteGreeting(TimeOfDay.afternoon);// 从字符串中获取枚举值,并转换为整数TimeOfDay time2 = (TimeOfDay)Enum.Parse(typeof(TimeOfDay), "afternoon", true);Console.WriteLine((int)time 阅读全文

posted @ 2013-02-23 17:17 LilianChen 阅读(522) 评论(0) 推荐(1) 编辑

C#: string 类型

摘要: 1. string是一个引用类型,但是其与引用类型在常见的操作上有一些区别:修改其中一个字符串,就会创建一个全新的string对象,而另一个字符串没有改变using System;namespace ConsoleApplication2{classProgram{staticvoid Main(string[] args){string s1 = "A string";string s2 = s1;Console.WriteLine("s1 is: " + s1);Console.WriteLine("s2 is: " + s2); 阅读全文

posted @ 2013-02-23 13:32 LilianChen 阅读(570) 评论(1) 推荐(1) 编辑

导航