摘要: Action Method Result动作方法结果ActionResultgeneric return value for an action and is used to perform a framework-level operation on behalf of the action method.通用的返回值的一个动作,是用来代表的动作方法执行框架级操作。ContentResultTo return a user-defined content type that is the result of an action method.要返回用户定义的内容类型的操作方法是这样的结果。E 阅读全文
posted @ 2013-09-29 19:17 yangzhenping 阅读(255) 评论(0) 推荐(0) 编辑
摘要: Html Helpers@Html.AntiForgeryTokenIt generates a hidden form field (anti-forgery token) that is validated when the form is submitted.它会产生一个隐藏的表单字段(防伪标记),提交表单时验证。@Html.AttributeEncodeTo convert the specified attribute value to an HTML-encoded string.HTML编码的字符串转换成指定的属性值。@Html.EncodeTo convert the spec 阅读全文
posted @ 2013-09-29 18:28 yangzhenping 阅读(293) 评论(0) 推荐(0) 编辑
摘要: Html帮助类used to render (modify and output) HTML form elements用来渲染HTML表单元素(修改和输出)Html.ActionLink输出: ..Html.BeginForm输出: Html.CheckBox输出: Html.DropDownList输出: Html.EndForm输出: Html.Hidden输出: Html.ListBox输出: Html.Password输出: Html.RadioButton输出: Html.TextArea输出: …Html.TextBox输出: Html.ValidationSummaryRetu 阅读全文
posted @ 2013-09-29 18:21 yangzhenping 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(306) 评论(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 阅读(527) 评论(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) 编辑
摘要: 重载构造函数:using System;public class Wine{ public decimal Price; public int Year; public Wine (decimal price) { Price = price; } public Wine (decimal price, int year) : this (price) { Year = year; }}对象初始化:public class Bunny{ public string Name; public bool LikesCarrots; public bool LikesHumans; ... 阅读全文
posted @ 2013-09-29 10:43 yangzhenping 阅读(546) 评论(0) 推荐(1) 编辑
摘要: 第一个C#程序:using System; // 导入命名空间class Test // 类声明 { static void Main () // 方法声明 { int x = 12 * 30; // 陈述1 Console.WriteLine (x); // 陈述2 } // 方法结束} ... 阅读全文
posted @ 2013-09-29 10:24 yangzhenping 阅读(333) 评论(0) 推荐(0) 编辑
摘要: App_StartIt has configuration classes to reduce clutter code in the Global.asax它包含了配置类来减少在Global.asax中的杂乱代码Application_Start 方法App_Start 文件夹里有如下文件:AuthConfig.cs: Related to security settings, including sites for OAuth login.关于安全设置,包含网站的授权登录。BundleConfig.cs: Related to register bundles for the bundli 阅读全文
posted @ 2013-09-29 08:42 yangzhenping 阅读(639) 评论(1) 推荐(0) 编辑