Is it possible to add to a system class?  
Author Message
Mythrandil





PostPosted: Visual C# Language, Is it possible to add to a system class? Top

For example could i add a method to System.Array

I know i could create a new class that inherits but would be nice to just tag it onto the system class!

Thanks


Visual C#20  
 
 
Peter Ritchie





PostPosted: Visual C# Language, Is it possible to add to a system class? Top

Not in C# 2.0 or less. In C# 3.0 you can create what they call "Extension methods" that essentially add a method to a class. See http://www.interact-sw.co.uk/iangblog/2005/09/26/extensionmethods for more details.