摘要: Attributes特性ActionFilterAttributeRepresents the base class for filter attributes.代表筛选器属性的基类。ActionMethodSelectorAttributeRepresents an attribute that is used to influence the selection of an action method.表示一个特性,用于一个操作方法的选择产生影响。ActionNameSelectorAttributeRepresents an attribute that affects the sele 阅读全文
posted @ 2013-09-29 18:19 yangzhenping 阅读(238) 评论(0) 推荐(0) 编辑
摘要: @{ Layout = “…”}To define layout page Equivalent to asp.net master-page要定义相当于ASP.NET母版页的页面布局@model To define strongly-typed model要定义强类型的模型@section { }To define named section定义命名节@RenderBodyUsed in layout as a placeholder for view’s entire content.用于布局视图的整个内容的占位符。@RenderPageRenders the content of on. 阅读全文
posted @ 2013-09-29 17:50 yangzhenping 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 使用XmlReader枚举结点: Jim BoXmlReaderSettings settings = new XmlReaderSettings();settings.IgnoreWhitespace = true;using (XmlReader reader = XmlReader.Create ("customer.xml", settings)) while (reader.Read()) { Console.Write (new string (' ',reader.Depth*2)); // Write indentation Console. 阅读全文
posted @ 2013-09-29 16:55 yangzhenping 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 高级转换:static IEnumerable ExpandPaths (IEnumerable paths){ var brokenUp = from path in paths let split = path.Split (new char[] { '\\' }, 2) orderby split[0] select new { name = split[0], remainder = s... 阅读全文
posted @ 2013-09-29 16:48 yangzhenping 阅读(144) 评论(0) 推荐(0) 编辑
摘要: Table 类:public class DemoDataContext : DataContext{ public DemoDataContext (string cxString) : base (cxString) {} public Table Customers { get { return GetTable(); } } public Table Purchases { get { return GetTable(); } }}[Table] public class Customer{ [Column(IsPrimaryKey=true)] public int ID;... 阅读全文
posted @ 2013-09-29 16:46 yangzhenping 阅读(231) 评论(0) 推荐(0) 编辑
摘要: 实现IEnumerable伴随一个迭代:public class MyGenCollection : IEnumerable{ int[] data = {1, 2, 3}; public IEnumerator GetEnumerator() { foreach (int i in data) yield return i; } IEnumerator IEnumerable.GetEnumerator() // Explicit implementation { // k... 阅读全文
posted @ 2013-09-29 16:38 yangzhenping 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 使用TimeZoneInfo:static void Main(){ TimeZoneInfo wa = TimeZoneInfo.FindSystemTimeZoneById ("W. Australia Standard Time"); Console.WriteLine (wa.Id); // W. Australia Standard Time Console.WriteLine (wa.DisplayName); // (GMT+08:00) Perth Console.WriteLi... 阅读全文
posted @ 2013-09-29 16:31 yangzhenping 阅读(307) 评论(0) 推荐(0) 编辑
摘要: [Bind(…)]Lists fields to exclude or include when binding parameter or form values to model properties列表字段时,排除或包括绑定参数或表单模型属性值[Compare("…")]To compare two properties.对比两个属性。[CreditCard]To Specify that a data field value is a credit card number.要指定一个数据字段的值是一个信用卡号码。[DataType(DataType.)]used fo 阅读全文
posted @ 2013-09-29 15:01 yangzhenping 阅读(499) 评论(3) 推荐(0) 编辑
摘要: Attributes特性[AcceptVerbs(…)]To specify HTTP verbs an action method will respond to.要指定HTTP动词的将响应的一个操作方法。[ActionName(…)]To define the name of an action定义一个动作的名称[AdditionalMetadata(…)]to populate the ModelMetadata.AdditionalValues dictionary for a model property.填充一个模型属性的ModelMetadata.AdditionalValues 阅读全文
posted @ 2013-09-29 12:44 yangzhenping 阅读(528) 评论(0) 推荐(0) 编辑
摘要: 使用delegates委托写插件方法:public delegate int Transformer (int x);public class Util{ public static void Transform (int[] values, Transformer t) { for (int i = 0; i (T arg);public class Util{ public static void Transform (T[] values, Transformer t) { for (int i = 0; i PriceChanged; protected vi... 阅读全文
posted @ 2013-09-29 11:16 yangzhenping 阅读(426) 评论(0) 推荐(0) 编辑