摘要:
特性(Attributes)是一种崭新的声明性信息。我们不仅可以通过特性来定义设计层面的信息(例如help file, URL for documentation)以及运行时(run-time)信息(例如使XML与class相联系),而且我们还可以利用特性建立自描述(self-describing)组件。在这篇教程中,我们将会看到如何建立和添加特性到各种程序实体以及如何在运行时环境中获取特性信息。 定义 正如MSDN中所描述的那样----- "特性是被指定给某一声明的一则附加的声明性信息。" 使用预定义(Pre-defined)特性 在C#中,有一个小的预定义特性集合。在学 阅读全文
posted @ 2011-12-28 11:46
dm3344
阅读(304)
评论(0)
推荐(0)
摘要:
//去掉字符串里面指定字符 比如"\n"string str = "sadasdas\nasdsa\n";string ss="";string[] sArray = System.Text.RegularExpressions.Regex.Split(str, "\n", System.Text.RegularExpressions.RegexOptions.IgnoreCase);foreach (string i in sArray){ss+= i;} 阅读全文
posted @ 2011-12-28 11:23
dm3344
阅读(307)
评论(0)
推荐(0)
摘要:
string s = "";if (definition != ""){char[] ch = new char[definition.Length];ch = definition.ToCharArray();for (int i = 0; i < definition.Length; i++){if (ch[i] == 39){s += ch[i] + "'";}else{s += ch[i];}}}respon.write(s); 阅读全文
posted @ 2011-12-28 11:21
dm3344
阅读(147)
评论(0)
推荐(0)
摘要:
枚举是一个特定的常量集合组成的独特类型using System;public enum TimeOfDay{ Morning = 0, Afternoon = 1, Evening}class EnumExample{ public static int Main() {//调用方法 WriteGreeting(TimeOfDay.Morning);//获取枚举字符串 TimeOfDay time = TimeOfDay.Afternoon; Console.WriteLine(time.ToString());//获取枚举字符串的值 TimeOfDay time2 = (TimeOfDay) 阅读全文
posted @ 2011-12-28 11:19
dm3344
阅读(287)
评论(0)
推荐(0)
浙公网安备 33010602011771号