views:

61

answers:

1

Hello,

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

+7  A: 

You're declaring your list to be the wrong type (non-generic):

IList test=new List<string>(); 

It should be

IList<String> test=new List<string>(); 
ck
Hello Ck, thanks a lot.
Josemalive