C#
局部類型適用於以下情況
(
(
(
局部類型是一個純語言層的編譯處理
public partial class Program
{
static void Main(string[] args)
{
}
}
partial class Program
{
public void Test()
{
}
}
(
(
(
(
(
(
在局部類型上的特性具有
[Attribute
partial class Class
[Attribute
partial class Class
相當於
[Attribute
class Class
注
(
(
(
(
(
(
partial class Class
partial class Class
partial class Class
相當於
class Class
把所有的源代碼作為一個類型保存在一個單獨的文件裡是一個好的編程習慣
Partial types允許把類
Partial
public partial class Customer
{
private int id;
private string name;
private string address;
private List<Order> orders;
public Customer() {
}
}
public partial class Customer
{
public void SubmitOrder(Order order) {
orders
}
public bool HasOutstandingOrders() {
return orders
}
}
當上面的兩個部分在一起編譯
public class Customer
{
private int id;
private string name;
private string address;
private List<Order> orders;
public Customer() {
}
public void SubmitOrder(Order order) {
orders
}
public bool HasOutstandingOrders() {
return orders
}
}
一個partial type的所有部分必須在一起編譯
From:http://tw.wingwit.com/Article/program/net/201311/12084.html