Extension Methods
Extension methods are a new feature in C# 3.0.
An extension method enables us to add methods to existing types without creating a new derived type, recompiling, or modify the original types.
An Extension Method is a static method to the existing static class
We call an extension method in the same general way, there is no difference in calling.
Feature and Property of Extension Methods:
It is static method.
It must be located in a static class.
It uses this keyword as the first parameter.
It also shown by VS intellisense. When we press the dot (.) after a type instance, then it comes in VS intellisense.
You can give any name for the class that has an extension method but the class should be static .
If you create extension methods that have the same signature methods as the type you are extending, then the extension methods will never be called.
ankpro
ankpro training
Asp.net MVC
C#
C sharp
Bangalore
Rajajinagar
Selenium
Coded UI
Mobile automation testing
Mobile testing
JQuery
JavaScript
.Net
Components of the .Net framework
Hello World
Literal
Keywords
Variable
Data types
Operators
Branching
Loops
Arrays
ArrayList
Strings
String Builder
Structures
Enums
Functions
Classes
Inheritance
Polymorphism
Properties
Indexers
Events
Nested Classes
Delegates
Anonymous methods
Labda expressions
Abstract classes
Exception Handling
Linq
Interfaces
Extension methods
Anonymous types
Generics
Collections
Garbage Collection
Reflection
Attributes
Input and output statements
Type casting
Partial Methods
Partial Classes
Boxing and Unboxing
Var vs Dynamic vs Object