Im trying to test my extension method that converts a list of strings in a string comma separated:
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
}
}
The issue is that in the method TestExtension i cant use ToCommaString method.
Do you know what’s happening?
Could i make available for all my web application this extension method registering in web.config or something similar?
Thanks in advance.
Best regards.
Jose
You’re declaring your list to be the wrong type (non-generic):
It should be