上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 18 下一页
摘要: 使用Hashtable没有任何优点,因为在.net2.0以后已经被Dictionary所代替。他们两者的区别是,根据stackoverflowDictionary relies on chaining (maintaining a list of items for each hash table bucket) to resolve collisions whereas Hashtable uses rehashing for collision resolution (when a collision occurs, tries another hash function to map t 阅读全文
posted @ 2013-08-30 18:43 瓜王 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 接口实现除了一般的隐式实现外,还有第二种方式:显示实现。explicit implement隐式实现可以同时用接口类型和子类型的实例调用,而显示实现只能用接口类型的实例调用。也就是说,显示实现时,类实例没有权限调用接口中的方法。并且,同时一个类可以同时用显示和隐式实现接口的同一个方法。那么,显示接口有什么用呢?根据http://stackoverflow.com/questions/143405/c-sharp-interfaces-implicit-implementation-versus-explicit-implementation显示实现可以帮助:1)让实现的类与接口解耦。2)再某些 阅读全文
posted @ 2013-08-29 18:39 瓜王 阅读(255) 评论(0) 推荐(0) 编辑
摘要: public class HomeController : Controller { public ActionResult Index() { //核心对象 IKernel ninjectKernel = new StandardKernel(); ninjectKernel.Bind().To(); //方案1:获取接口实例 IValueCaculator calImpl = ninjectKernel.Get(); ... 阅读全文
posted @ 2013-08-27 14:29 瓜王 阅读(267) 评论(0) 推荐(0) 编辑
摘要: 根据effective c#一书,作者建议一般可以放在初始化器中,除非1)初始化为null或02)有若干个构造函数3)需要异常捕获 阅读全文
posted @ 2013-08-27 09:44 瓜王 阅读(488) 评论(0) 推荐(0) 编辑
摘要: asp.net mvc2新特性:1、区域,有利于分模块开发 2、数据注解和验证 3、View层强类型辅助方法 4、UI Templates 5、httppost,默认参数asp.net mvc3新特性: 1、Razor视图引擎 2、Ajax.ActionLink,Ajax.RouteLink,Ajax.BeginForm和Ajax.BeginRouteForm 3、Nu... 阅读全文
posted @ 2013-08-22 15:59 瓜王 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 属性:提供对私有字段的权限和方式访问封装。特性:为目标元素提供关联的附件信息,在运行时以反射的方式影响程序的行为。目标元素包括:程序集,模块,类,类型,属性,方法,甚至函数参数。主要应用:序列化,编译器指令,设计模式等方面。AttributeUsage:只能放在其他特性定义上,用来规范其权限DllImport:导入已有的非托管代码,只能放置在方法上。特性列表http://msdn.microsoft.com/en-us/library/aa311259(VS.71).aspx 阅读全文
posted @ 2013-08-21 13:22 瓜王 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 接受数据接口: public ActionResult PostDownloadLog(PostDownloadLog postDownloadLogs)PostDownLoadLogL类public class PostDownloadLog{public List DownloadLogs { get; set; }}UbtCourseDownload类 public class UbtCourseDownload { public string Id{get;set;} public string WWID { get; set; } ... 阅读全文
posted @ 2013-08-21 11:37 瓜王 阅读(1341) 评论(0) 推荐(0) 编辑
摘要: dynamic是c# 4.0新增的类型,可以修饰类,对象,属性,索引器,方法返回值等。class ExampleClass{ // A dynamic field. static dynamic field; // A dynamic property. dynamic prop { get; set; } // A dynamic return type and a dynamic paramater type. public dynamic exampleMethod(dynamic d) { // A dynamic local v... 阅读全文
posted @ 2013-08-16 17:53 瓜王 阅读(857) 评论(0) 推荐(0) 编辑
摘要: Find方法和FirstOrDefault方法效果相同,都是返回满足条件的第一个元素,如果没有该元素,则返回null。那么这两个扩展方法有什么不同?1)Find方法是.netFramework2.0的,而FirstOrDefault是3.5的。2)Find方法只能在List上使用,而后者能更广泛应用在IEnemerable上。3)依据http://stackoverflow.com/questions/14032709/performance-of-find-vs-firstordefault一文,Find最终是建立在Array的查找之上,而在IEnemerable上的FirstOrDefau 阅读全文
posted @ 2013-08-16 10:34 瓜王 阅读(16085) 评论(2) 推荐(4) 编辑
摘要: 开放封闭原则(OCP,Open Closed Principle)是面向对象原则的核心。由于软件设计本身所追求的墓边就是封装变化,降低耦合,而开放封闭原则就是对这一目标的直接体现。(你必须知道的.NETp48页)以下用例子说明,同样来自该书。假设在一个柜台业务处理系统,首先有客户: public class Client { public string Name{get;set;} private string ClientType { get; set; } }ClientType表示客户的类型,如"存款用户","转账用户","取款用户&qu 阅读全文
posted @ 2013-08-12 18:42 瓜王 阅读(409) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 18 下一页