Partial Method Declaraion And Implementation C# with Example



Partial Method Declaraion And Implementation C# with Example

 	using System;

	namespace CSharpClass
	{
		partial class MyClass
		{ 
			partial void PrintSum(int x, int y); 		// Declaring partial method (Prototype)

			public void Add(int x, int y)
			{
				PrintSum(x, y);
			}
		}
			
		partial class MyClass
		{
				partial void PrintSum(int x, int y) // Implementing partial method (Definition)
			{
				Console.WriteLine("Sum is {0}", x + y); 
			}
		}
		
		class Program
		{
			static void Main( )
			{
				var mc = new MyClass();
				mc.Add(5, 6);
			}
		}
	}
 

0 Comment's

Comment Form

Submit Comment