I have tried this:
public static class ListHelper
{
public static string ToString(this IList list)
{
return string.Joi
It sounds like you want to replace what files.ToString() returns. You will not be able to do that without writing a custom class to assign files as (i.e. inherit from List and override ToString().)
First, get rid of the generic type (), you're not using it. Next, you will need to rename the extension method because calling files.ToString()will just call the List's ToString method.
This does what you're looking for.
static class Program
{
static void Main()
{
var list = new List { {"a"}, {"b"}, {"c"} };
string str = list.ToStringExtended();
}
}
public static class ListHelper
{
public static string ToStringExtended(this IList list)
{
return string.Join(", ", list.ToArray());
}
}