What is partial methods in c#
What is partial methods in c#? How and when to use it.
Views: 8112 Total Answered: 1 Total Marked As Answer: 1 Posted On:
Partial methods are introduce in .Net framework 3.0. So you can split the definition of a class or a struct, an interface or a method over two or more source files. Each source file contains a section of the type or method definition, and all parts are combined when the application is compiled.
Example for partial method
// Definition in file1.cs
partial void onNameChanged();
// Implementation in file2.cs
partial void onNameChanged()
// method body
There are some conditions for partial methods:
- Signatures in both parts of the partial type must match.
- The method must return void.
- No access modifiers are allowed. Partial methods are implicitly private.
Posted On: 16-Apr-2016 01:09