I have a ToString extension method of an IEnumerable, which converts it to a list of strings as follows:
public static string ToString<T>(this IEnumerable<T> theSource,
string theSeparator) where T : class
{
string[] array =
theSource.Where(n => n != null).Select(n => n.ToString()).ToArray();
return string.Join(theSeparator, array);
}
I now want to do something similar with an array of enums: given theXStatuses, an array of XStatus enum values, I want to get a string containing the enum values separatd by theSeparator. For some reason, the above extension method doesn't work for XStatus[]. So I tried
public static string ToString1<T>(this IEnumerable<T> theSource,string theSeparator)
where T : Enum
But then I got an error that "cannot use ... 'System.Enum'...as type parameter constraint.
Is there any way to achive this?