What is Partial Methods in C# ?

Forums C#What is Partial Methods in C# ?
Staff asked 3 years ago

What are Partial Methods in C#?

Answers (1)

Add Answer
Faisal Pathan Marked As Accepted
Staff answered 3 years ago

In simple terms, we can say that the method declaration part is in one partial class and the definition part in another partial class or may contain declaration and definition in the same partial class.

for example:

Car.cs

public partial class Car
{  
    partial void CalcPrice(decimal price);  
}

Car2.cs

public partial class Car 
{ 
    partial void CalcPrice(decimal price)
    {
       price = price * 5000;
       Console.WriteLine("Car price is : {0}", price);
    }
}

 

 

Subscribe

Select Categories