随笔分类 -  C# 2.0 & 3.0

摘要:using System.Diagnostics; namespace WebApplication1{ public partial class WebForm3 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Process pro = new Proce... 阅读全文
posted @ 2009-04-30 09:40 许晓光 阅读(598) 评论(0) 推荐(0)
摘要:怎样实现对所有类可读但是在同一个assembly可写那? 答案: 同一个assembly namespace ClassLibrary1 { public class Class1 { public string Name { get; internal set; } } publi... 阅读全文
posted @ 2009-04-08 17:42 许晓光 阅读(231) 评论(0) 推荐(0)
摘要:The following categories of variables are automatically initialized to their default values: Static variables. Instance variables of class instances. Array elements. The default value ... 阅读全文
posted @ 2008-10-09 10:39 许晓光 阅读(548) 评论(0) 推荐(0)
摘要:1.局部变量必须赋初始值 class Example { public void GetMoney() { int pp1; object pp2; Console.WriteLine(pp1); Console.WriteLine(pp2); } } Result: Error 3 Us... 阅读全文
posted @ 2008-10-08 17:13 许晓光 阅读(189) 评论(0) 推荐(0)
摘要:声明destructor Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->1 public class Test 2 { 3 ~Test() 4 { 5 } 6 } 7 编译后的M... 阅读全文
posted @ 2008-08-27 09:36 许晓光 阅读(830) 评论(0) 推荐(0)
摘要:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> 1 class Program 2 { 3 static void Main() 4 { 5 int [] ar = {1,2,3,4,5}; 6 7 //IEnumerable ... 阅读全文
posted @ 2008-08-04 11:35 许晓光 阅读(156) 评论(0) 推荐(0)
摘要:A lambda expression is an anonymous funtion that can contain expressions and statements, Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> 1 class Pr... 阅读全文
posted @ 2008-08-01 14:14 许晓光 阅读(157) 评论(0) 推荐(0)
摘要:You can use Extension Methods to add methods to existing types without declaring a new derived type, recomelling... Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHig... 阅读全文
posted @ 2008-07-31 10:24 许晓光 阅读(190) 评论(0) 推荐(0)
摘要:代码如下: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->1 List scores = new List{88,99}; 阅读全文
posted @ 2008-07-30 10:47 许晓光 阅读(134) 评论(0) 推荐(0)
摘要:代码如下: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> 1 public class Mobile 2 3 { 4 5 public int Length { get; set; } 6 7 public int Width... 阅读全文
posted @ 2008-07-29 14:59 许晓光 阅读(169) 评论(0) 推荐(0)
摘要:1.Partial Classes(部分类) Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> 1 public partial class Part 2 { 3 public void GetMoney() 4 ... 阅读全文
posted @ 2008-07-28 10:43 许晓光 阅读(229) 评论(0) 推荐(0)
摘要:var v = new { Amount = 108, Message = "Hello" }; 阅读全文
posted @ 2008-07-25 16:22 许晓光 阅读(112) 评论(0) 推荐(0)
摘要:public class Mobile { public int Length { get; set; } public int Width { get; set; } } 阅读全文
posted @ 2008-07-24 17:31 许晓光 阅读(219) 评论(0) 推荐(0)
摘要:在.NET中,string数据类型很特别,它本身是引用类型,这是毫无疑问的.但是有时它表现出让人困惑的行为! Scenario1: C#代码1:结果是True Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> 1 namespace Strin... 阅读全文
posted @ 2008-07-24 16:19 许晓光 阅读(189) 评论(0) 推荐(0)
摘要:Although an abstract method is implicitly also a virtual method, it cannot have the modifier virtual. Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com... 阅读全文
posted @ 2008-07-22 10:09 许晓光 阅读(174) 评论(0) 推荐(0)
摘要:密封方法阻止继承类进一步的重写该方法。 public sealed override void Test() { //do it } http://msdn.microsoft.com/en-us/library/aa645769(VS.71).aspx 阅读全文
posted @ 2008-07-21 15:35 许晓光 阅读(284) 评论(0) 推荐(0)
摘要:The method overridden by an override declaration is known as the overridden base method. For an override method M declared in a class C, the overridden base method is determined by examining each base... 阅读全文
posted @ 2008-07-21 14:58 许晓光 阅读(184) 评论(0) 推荐(0)
摘要:The implementation of a non-virtual method is invariant: The implementation is the same whether the method is invoked on an instance of the class in which it is declared or an instance of a derived cl... 阅读全文
posted @ 2008-07-10 10:57 许晓光 阅读(292) 评论(0) 推荐(0)
摘要:在C# 多层继承中,如果创建子类,实际上同时也创建了基类对象。 阅读全文
posted @ 2008-07-09 14:25 许晓光 阅读(273) 评论(0) 推荐(0)
摘要:多态: 1 public class Women 2 { 3 public void DoWork() { } 4 } 5 6 public class Girl : Women 7 { 8 public new void DoWork() { } 9 } 10 11 class Main 12 { 13 static void Main() ... 阅读全文
posted @ 2008-07-08 16:51 许晓光 阅读(290) 评论(0) 推荐(0)