The partial class help you separate your class to multiple files. As you know, C# provides the ability to have a single class implementation in multiple .cs files using the partial modifier keyword
For Example
Student1.cs
using System;
namespace CSharp
{
public partial class Student
{
public void Add()
{
Console.WriteLine("Add student !");
}
public void Edit()
{
Console.WriteLine("Edit student !");
}
//...etc
}
}
Student2.cs
using System;
namespace CSharp
{
public partial class Student
{
public void Show()
{
Console.WriteLine("Display student information !");
}
}
}
In main class you can use the partial class as shown below
using System;
namespace CSharp
{
class Program
{
static void Main(string[] args)
{
Student obj = new Student();
obj.Add();
obj.Show();
}
}
}
You can also apply partial modifier to a class, method, interface or structure