Partial methods C# with Example



Partial methods C# with Example

Partial method consists of the definition in one partial class declaration (as a common scenario - in the auto- 
generated one) and the implementation in another partial class declaration. 
using System; 
namespace PartialClassAndMethods 
{ 
public partial class PartialClass // Auto-generated 
{ 
partial void PartialMethod(); 
} 
public partial class PartialClass // Human-written 
{ 
public void PartialMethod() 
{ 
Console.WriteLine("Partial method called."); 
} 
} 
class Program 
{ 
static void Main(string[] args) 
{ 
PartialClass partial = new PartialClass(); 
partial.PartialMethod(); // outputs "Partial method called." 
} 
} 
} 
 

0 Comment's

Comment Form

Submit Comment