ITeye博客

.NET 2.0分部类

winzenghua · 2007-09-03 09:36 · Markdown

分部类型的所有部分必须一起编译,以使这些部分可在编译时被合并。特别指出的是,分部类型不允许对已经编译的类型进行扩展.

public partial class CoOrds
{
private int x;
private int y;

public CoOrds(int x, int y)
{
this.x = x;
this.y = y;
}
}

public partial class CoOrds
{
public void PrintCoOrds()
{
System.Console.WriteLine("CoOrds: {0},{1}", x, y);
}

}

class TestCoOrds
{
static void Main()
{
CoOrds myCoOrds = new CoOrds(10, 15);
myCoOrds.PrintCoOrds();
}
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。