When we want to split class we use partial keyword. The main advantage of partial
class is that more than one programmer can work on same class at a time i.e. they
can implement same class.
Example
private void btnAdd_Click(object sender, EventArgs e)
{
//creating instance of class
c c1 = new c();
//calling add() method of class
MessageBox.Show(c1.add(2,4).ToString());
}
private void btnSub_Click(object sender, EventArgs e)
{
c c1 = new c();
//calling sub() method of class
MessageBox.Show(c1.sub(4,3).ToString());
}
//half of the class is defined here
public partial class c
{
public int add(int a, int b)
{
return a+b;
}
}
//another half of class c
public int sub(int a, int b)
{
return a - b;
}
Screen shots
Anonymous User
31-Jan-2019Nice Article