随笔分类 - 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...
阅读全文
摘要:怎样实现对所有类可读但是在同一个assembly可写那? 答案: 同一个assembly namespace ClassLibrary1 { public class Class1 { public string Name { get; internal set; } } publi...
阅读全文
摘要:The following categories of variables are automatically initialized to their default values: Static variables. Instance variables of class instances. Array elements. The default value ...
阅读全文
摘要:1.局部变量必须赋初始值 class Example { public void GetMoney() { int pp1; object pp2; Console.WriteLine(pp1); Console.WriteLine(pp2); } } Result: Error 3 Us...
阅读全文
摘要:声明destructor Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->1 public class Test 2 { 3 ~Test() 4 { 5 } 6 } 7 编译后的M...
阅读全文
摘要: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 ...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:代码如下: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->1 List scores = new List{88,99};
阅读全文
摘要:代码如下: 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...
阅读全文
摘要: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 ...
阅读全文
摘要:var v = new { Amount = 108, Message = "Hello" };
阅读全文
摘要:public class Mobile { public int Length { get; set; } public int Width { get; set; } }
阅读全文
摘要:在.NET中,string数据类型很特别,它本身是引用类型,这是毫无疑问的.但是有时它表现出让人困惑的行为! Scenario1: C#代码1:结果是True Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> 1 namespace Strin...
阅读全文
摘要: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...
阅读全文
摘要:密封方法阻止继承类进一步的重写该方法。 public sealed override void Test() { //do it } http://msdn.microsoft.com/en-us/library/aa645769(VS.71).aspx
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:在C# 多层继承中,如果创建子类,实际上同时也创建了基类对象。
阅读全文
摘要:多态: 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() ...
阅读全文

浙公网安备 33010602011771号