Extension method on type
Posted
by Karsten
on Stack Overflow
See other posts from Stack Overflow
or by Karsten
Published on 2009-10-16T12:01:05Z
Indexed on
2010/05/15
22:50 UTC
Read the original article
Hit count: 473
Hi
Is there a way to create an extension method for an type ? I only seem to be able to create them for instances.
public static class MyExtensions
{
public static string Test(this string s)
{
return "test";
}
}
public class Test
{
static void TestIt()
{
string.Test(); // won't compile
string s = null;
s.Test();
}
}
© Stack Overflow or respective owner