-1

Hi I want to create a List in a List, I make that

public List<List<int>> CellsByNumero = new List<List<int>>() { { 1, 7, 13, 18, 19, 25, 31 },{1, 2, 3, 25, 26, 27, 31, 32, 33 } };

but I have an error for each list, Is there a way to do that? or should I use Add for each List?

Sevlac
  • 39
  • 8
  • Yes, Thank you. Sorry for the repost, I didn't find this one ^^' – Sevlac Aug 28 '22 at 16:57
  • 1
    Note the accepted answer to [Succinct syntax for initializing list of lists](https://stackoverflow.com/q/13586325/3744182) is not up-to-date with c# 9.0/.NET 5, so I added another that uses target-typed `new()` expressions. – dbc Aug 28 '22 at 17:10

1 Answers1

1
List<List<int>> CellsByNumero = new List<List<int>>() { new List<int>{ 1, 7, 13, 18, 19, 25, 31 }, new List<int>{ 1, 2, 3, 25, 26, 27, 31, 32, 33 } };
Qwerty
  • 429
  • 2
  • 8