【发布时间】:2010-08-27 07:41:26
【问题描述】:
我正在尝试测试我的扩展方法,该方法将字符串列表转换为逗号分隔的字符串:
public static class Extensions
{
public static string ToCommaString<T>(this IList<T> input)
{
StringBuilder sb = new StringBuilder();
foreach (T value in input)
{
sb.Append(value);
sb.Append(",");
}
return sb.ToString();
}
public void TestExtension()
{
IList test=new List<string>();
//test.ToCommaString doesnt appear
}
}
问题是在 TestExtension 方法中我不能使用 ToCommaString 方法。
你知道发生了什么吗?
我可以为我的所有 Web 应用程序提供在 web.config 中注册的扩展方法或类似的东西吗?
提前致谢。
最好的问候。
何塞
【问题讨论】:
标签: asp.net asp.net-mvc-2 oop extension-methods