It is use to break/split the definition of a class in more than two or more classes. It is done in the same namespace. All the parts should contain partial keyword.
Let us take an example to understand this..
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication11 { partialclassA
{ publicvoid Function1()
{ Console.WriteLine("You are in Function1");
}
} partialclassA
{ publicvoid Function2()
{ Console.WriteLine("You are in Function2");
}
} classProgram
{ staticvoid Main(string[] args)
{ A obj = newA(); obj.Function1(); obj.Function2();
}
} }
You will get the following Output:
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
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.
Partial Class
It is use to break/split the definition of a class in more than two or more classes. It is done in the same namespace. All the parts should contain partial keyword.
Let us take an example to understand this..