This snippet:
static Tuple<IEnumerable<string>, IEnumerable<string>> GetTwoLists()
{
var list1 = new List<string> { "one", "two" };
var list2 = new List<string> { "uno", "dos" };
return Tuple.Create(list1, list2);
}
fails to compile with error:
Cannot implicitly convert type
'System.Tuple<System.Collections.Generic.List<string>, System.Collections.Generic.List<string>>'
to'System.Tuple<System.Collections.Generic.IEnumerable<string>, System.Collections.Generic.IEnumerable<string>>'
It succeeds with an explicit cast. That is:
return Tuple.Create(list1 as IEnumerable<string>, list2 as IEnumerable<string>);
Why is the cast required here? Isn't List<string>
an IEnumerable<string>
?