08 2012 档案

摘要:using System;using System.Runtime.Serialization;using System.Security.Permissions;namespace GenericException{ [Serializable] public sealed class Exception<TExceptionArgs> : Exception, ISerializa... 阅读全文
posted @ 2012-08-22 23:24 HelloWorld.Michael 阅读(231) 评论(0) 推荐(0)
摘要:在try块中的代码(或者从try块调用的任何方法)抛出异常,CLR将搜索捕捉类型与抛出的异常相同(或是它的基类)的catch块。如果没有任何捕捉类型与抛出的异常匹配,CLR会去调用栈的更高一层搜索一个异常匹配的捕捉类型。如果到了调用栈顶部,还是没有找到具有匹配捕捉类型的一个catch块,就会发生一个未处理的异常。 一旦CLR找到一个具有匹配捕捉类型的catch块,就会执行内层所有的finally... 阅读全文
posted @ 2012-08-22 23:21 HelloWorld.Michael 阅读(114) 评论(0) 推荐(0)
摘要:[ComVisible(true)] [Serializable] public enum StringComparison { CurrentCulture, CurrentCultureIgnoreCase, InvariantCulture, InvariantCultureIgnoreCase, ... 阅读全文
posted @ 2012-08-22 21:04 HelloWorld.Michael 阅读(782) 评论(0) 推荐(0)
摘要:Server-side validation Server-side validation should be done whether we validate on the client or not. Users could disable JavaScript or do something unexpected to bypass client-side validation, and ... 阅读全文
posted @ 2012-08-20 17:22 HelloWorld.Michael 阅读(486) 评论(0) 推荐(0)
摘要:主要约束:主要约束可以是一个引用类型,标识了一个没有密封的类。指定一个引用类型约束时,相当于向编译器承诺:一个指定类型的实参要么是与约束类型相同的类型,要么是从约束类型派生的一个类型。如果一个类型参数没有指定主要约束,就默认认为System.Object。有两个特殊的主要约束:class和struct。其中class想编译器承诺一个指定的类型实参是引用类型 internal sealed ... 阅读全文
posted @ 2012-08-15 22:44 HelloWorld.Michael 阅读(376) 评论(0) 推荐(0)
摘要:泛型委托:委托实际只是提供了4个方法的一个类定义。这4个方法包括:一个构造器、一个Invoke方法、一个BeginInvoke方法和一个EndInvoke方法。如果定义的一个委托类型指定了类型参数,编译器会定义委托类的方法,用指定的类型参数替换方法的参数类型和返回值类型 利用逆变或者协变,可以将泛型委托类的一个变量转型为同一个委托类型的另一个变量,后者的泛型参数类型不同 不变量(invaria... 阅读全文
posted @ 2012-08-15 22:04 HelloWorld.Michael 阅读(431) 评论(0) 推荐(0)
摘要:HTML helper Description DisplayFor Returns HTML markup for each property in the object that’s represented by the expression ... 阅读全文
posted @ 2012-08-15 13:57 HelloWorld.Michael 阅读(212) 评论(0) 推荐(0)
摘要:There are three different ways in which data can be passed to a view by using the ViewDataDictionary, the ViewBag, and strongly typed views. ViewDataDictionary public ViewResult Show(int id) ... 阅读全文
posted @ 2012-08-15 11:18 HelloWorld.Michael 阅读(212) 评论(0) 推荐(0)
摘要:By Default:public ActionResult Create(){ return View();}Calling the View method returns a ViewResult object that knows how to render a particular view. When this method is called with no arguments,... 阅读全文
posted @ 2012-08-15 11:03 HelloWorld.Michael 阅读(157) 评论(0) 推荐(0)
摘要:实例构造器:作用是设置类型的实例的初始状态 类型构造器:即static构造器,作用是设置类型的初始状态(通常是初始化静态字段)。类型默认没有定义类型构造器,如果定义也只能定义一个。此外,类型构造器永远没有参数 实例构造器的调用:JIT编译器在编译一个方法时,会查看代码中都引用了哪些类型。任何一个类型定义了类型构造器,JIT编译器都会检查对当前AppDomain,是否已经执行了这个类型构造器。如... 阅读全文
posted @ 2012-08-14 00:19 HelloWorld.Michael 阅读(177) 评论(0) 推荐(0)
摘要:静态类必须直接从System.Object派生,从其他任何基类派生没有任何意义。无法创建静态类的实例 静态类不能实现任何接口,这是因为只有使用类的一个实例时,才可以调用类的接口方法 静态类只能定义静态成员(字段、方法、属性和事件),任何实例成员都将导致编译器报错 静态类不能作为字段、方法参数或者局部变量使用,因为它们都代表引用了一个实例的变量 C#编译器将静态类标记为... 阅读全文
posted @ 2012-08-13 00:16 HelloWorld.Michael 阅读(280) 评论(0) 推荐(0)
摘要:基元(Primitive):在代码中可以使用的最简单构造 用户模式基元:使用特殊的CPU指令来协调线程,即协调是在硬件中发生的,速度很快。但是Windows永远检测不到一个线程在一个基元用户模式中够钟上阻塞了。所以,想要取得一个资源但又暂时娶不到一个线程会一直在用户模式中运行,这可能浪费大量的CPU时间 内核模式基元:要求应用程序的线程中调用在操作系统内核中实现的函数。一个线程使用一个内核模式... 阅读全文
posted @ 2012-08-08 00:15 HelloWorld.Michael 阅读(465) 评论(0) 推荐(1)