Материал из .Net Framework эксперт
A partial class can span multiple source files.
using System;
public partial class MyClass {
public void CoreMethodA() {
Console.WriteLine("MyClass.CoreA");
}
}
public class Starter {
public static void Main() {
MyClass obj = new MyClass();
obj.CoreMethodA();
obj.ExtendedMethodA();
}
}
public partial class MyClass {
public void ExtendedMethodA() {
Console.WriteLine("MyClass.ExtendedA");
}
}
Define and use partial class
using System;
partial class XY {
int x;
public int X {
get { return x; }
set { x = value; }
}
}
partial class XY {
int y;
public int Y {
get { return y; }
set { y = value; }
}
}
class MainClass {
public static void Main() {
XY xy = new XY();
Console.WriteLine(xy.X + "," + xy.Y);
}
}
0,0
generic partial class
using System;
using System.ruponentModel;
partial class Example<TFirst, TSecond>: IEquatable<string>where TFirst : class
{
public bool Equals(string other)
{
return false;
}
}