2012-09-07 10 views

risposta

16
var list = new List<string[]> 
{ 
    new[] { "One", "Two", "Three" }, 
    new[] { "Four", "Five", "Six" } 
}; 
+0

Sì, questo funziona. Grazie! – user1306322

2

vuoi dire questo?

var stringList = new List<string[]> 
{ 
    new string[] { "stringa1", "stringa2", "stringa3" }, 
    new string[] { "stringb1", "stringb2", "stringb3" }, 
    new string[] { "stringc1", "stringc2", "stringc3" } 
}; 
1
var list_array = new List<string[]> { 
    new[]{"a", "b", "c" }, new[] {"f", "g", "h"}}; 
+0

Does 'new []' prende il suo tipo dalla lista, come 'var'? – user1306322

+1

Sì, il tipo viene dedotto dai valori nella matrice. Vedere [qui] (http://msdn.microsoft.com/en-us/library/bb384090.aspx) – SwDevMan81

1
var test = new List<string> { "test", "test2" }; 
+0

Che funzionerebbe se l'OP stesse usando 'Lista ', ma in realtà 'Elenco ' – SwDevMan81

+0

@ SwDevMan81. ..lo vedo ora, grazie. –

Problemi correlati