2009年2月27日星期五

关于自动属性,一丁点,好看不中用,没技术含量

using System;
public abstract class ClassBase
{
public abstract int IProperty {get;set;}
}
public class ClassA : ClassBase
{
public override int IProperty {get;set;}
}
public class Program
{
public static void Main()
{
ClassBase b = new ClassA();
b.IProperty = 5;
Console.WriteLine("i = {0}", b.IProperty);
}
}
因为针对自动属性的{get;set;}简要写法,显然除了abstract和override的差别之外,别无其他。因为没有什么发现,就记录在这里了,不到别的地方去丢人现眼了。呵呵。
1.Save all code as a file named "abstract.gc" or other.
2.Run the "Windows Command prompt" or "Visual Studio 2008 Command Prompt" tools.
3.Setup the compile environment. (Visual Studio 2008 Command Prompt not do this step.)
4.Use the csc command to compile.
>> {path}>csc abstract.gc
5.Run the program.
>> {path}>abstract

没有评论: