
Untitled
By: a guest on
Apr 25th, 2012 | syntax:
None | size: 1.14 KB | hits: 12 | expires: Never
What is the purpose of partial classes?
public partial class MyClass : IDataErrorInfo
{
partial void ValidateMyProperty(ref string error);
public string this[string propertyName]
{
get
{
string error = String.Empty;
if (propertyName == "MyProperty")
ValidateMyProperty(ref error);
return error;
}
}
public string Error { get { return String.Empty; } }
public int MyProperty { get; set; }
}
public partial class MyClass
{
partial void ValidateMyProperty(ref string error)
{
if (MyProperty < 0)
error = "MyProperty cannot be negative.";
}
}
public partial class testClass {
private int intMember;
public string stringMember;
}
public partial class testClass {
private int intAnotherInt;
public string stringAnotherString;
}
public partial class testClass {
private int intAnotherInt; // Our int from HelloWorld2.cs
public string stringAnotherString; // Our string from HelloWorld2.cs
private int intMember; // Our int from HelloWorld.cs
public string stringMember; // Our string from HelloWorld.cs
}