A partialclass can be defined as the class that can be split among multiple physical files. This feature came in C# 2.0. The partial class break the definition of class into two or more than two class files, but it will be together at compile time as one class.
Every class in C# resides in a separate physical file with a .cs extension. C# provides an ability to have a single class implementation in multiple .cs files using the partial modifier keyword. The partial modifier can be applied to any class, method, interface or structure.
For example, this MyPartialClass splits into two files, PartialClassFile1.cs and PartialClassFile2.cs:
Example:
PartialClassFile1.cs
public partial class MyPartialClass
{
public MyPartialClass()
{
}
public void Method1(int val)
{
Console.WriteLine(val);
}
}
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
A partial class can be defined as the class that can be split among multiple physical files. This feature came in C# 2.0. The partial class break the definition of class into two or more than two class files, but it will be together at compile time as one class.
Every class in C# resides in a separate physical file with a .cs extension. C# provides an ability to have a single class implementation in multiple .cs files using the partial modifier keyword. The partial modifier can be applied to any class, method, interface or structure.
For example, this MyPartialClass splits into two files, PartialClassFile1.cs and PartialClassFile2.cs:
Example:
PartialClassFile1.cs