Kar*_*ten 2 c# extension-methods c#-3.0
有没有办法为类型创建扩展方法?我似乎只能为实例创建它们.
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();
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
136 次 |
| 最近记录: |