---
title: ".NET 2.0分部类"
author: "winzenghua"
date: "2007-09-03T09:36:00Z"
tags: []
slug: "net-2-0"
draft: false
lastmod: "2007-09-03T09:36:00Z"
id: 952949
url: "https://java4gis.iteye.com/blog/952949"
---

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

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();  
}  
}