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
public partial class MyPartialClass
{
public MyPartialClass()
{
}
public void Method1(int val)
{
Console.WriteLine(val);
}
}
Liked By
Write Answer
Define Partial class in MVC.
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
Join MindStick Community
You have need login or register for voting of answers or question.
Nishi Tiwari
22-Jan-2020A 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