private List> GetCardMatchesInHand()
{
List list4;
List> list = new List
It's trying to do the equivalent of:
List<Card> tmp = new List<Card>();
tmp.Add(list2);
tmp.Add(list3);
tmp.Add(list4);
List<Card> list4 = tmp;
Now you can't call Add
with a list of the element type - which is why you're getting that error. You're also trying to use list4
when assigning a value to list4
for the first time.
It's not really clear what you're trying to achieve, but if you want list4
to be all the elements of list2
and list3
, you can use:
List<Card> list4 = list2.Concat(list3).ToList();
Or if you really wanted list4
to be a list of lists, you need to declare it that way and call the appropriate constructor:
// Note not using list4 within the initializer...
List<List<Card>> list4 = new List<List<Card>> { list2, list3 };
Your whole metho looks a little confused at the moment - you're not using the list
variable at all, and you're declaring list4
much earlier than you use it. Neither of these is an error, but both are a little odd.