How to extend methods to a class not to its instances.
- by Fraga
Hi.
Extending methods to any instance is really easy:
public static string LeaveJustNumbers(this string text)
{
return Regex.Replace(text, @"[\D]", "");
}
...
string JustNumbers = "A5gfb343j4".LeaveJustNumber();
But what if i want to extend methods to a sealed class like string, to
work like:
string.Format("Hi:{0}","Fraga");
Is there any way to do it?