Understanding Extension Methods

Assalamualaykum wr br…Today we understand the concept of EXTENSION METHODS.
Extension Methods allows us to add Methods to existing types without recompiling, modifying the existing types. These are the special types of static methods which can be called just like existing methods in types. It uses “this” keyword in the parameter that differs from the other methods.
“this” keyword in the parameter section of the method. It tells the compiler that this is an extension method for the string class, and that’s actually all you need to create an extension method.
The following code demonstrates the implementation of Extension methods shown as:
extension
The corresponding output of the code shown above is:
extensions_output
Hope understood well…we meet soon with lot of stuff..till then Good Bye
Jazakallah khair…

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s