I've been teaching myself LINQ recently and applying it to various little puzzles. However, one of the problems I have run into is that LINQ-to-objects only works on generic collections. Is there a secret trick/ best practice for converting a non-generic collection to a generic collection?
My current implementation copies the non-generic collection to an array then operates on that, but I was wondering if there was a better way?
public static int maxSequence(string str)
{
MatchCollection matches = Regex.Matches(str, "H+|T+");
Match[] matchArr = new Match[matches.Count];
matches.CopyTo(matchArr, 0);
return matchArr
.Select(match => match.Value.Length)
.OrderByDescending(len => len)
.First();
}