Extension method: Difference between revisions

Content deleted Content added
rewrite
Line 49:
class AlphabetMaker
{
public void GetAlphabet()
{ //When this method is implemented,
{ Console.WriteLine("abc"); //it will shadow the implementation
} Console.WriteLine("abc"); //in the ExtensionMethods class.
}
}
 
static class ExtensionMethods
{
static public void GetAlphabet(this AlphabetMaker am) //This will only be called
{ //This will only be called //if there is no instance
Console.WriteLine("ABC"); //methodif withthere theis sameno signature.instance
} //method with the same signature.
}
}
</source>