Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Extension methods and Methods in C#

What is the difference between Extension Methods and Methods in C#?

like image 602
Thomas Anderson Avatar asked Dec 09 '22 12:12

Thomas Anderson


1 Answers

I think what you are really looking for is the difference between Static and Instance Methods

At the end of the day Extension methods are some nice compiler magic and syntactic sugar that allow you to invoke a Static method as though it were a method defined on that particular class instance. However, it is NOT an instance method, as the instance of that particular class must be passed into the function.

like image 131
Josh Avatar answered Jan 31 '23 17:01

Josh