c# - Split string input into jagged array -


string[] listkeys = key.split(','); string[] orkeys; string[][] advlistkeys; (int = 0; < listkeys.length; i++) {     orkeys = listkeys[i].split('|');     (int j = 0; j < orkeys.length; j++)     {         advlistkeys = new string[i][j];         advlistkeys[i][j] = orkeys[i];     } } 

i trying enter string "glu|com,inf|ina" jagged array in c# in such way it's columns defined length of listkeys (split comas) , rows defined length of orkeys (split '|') , values stored in jagged array {"glu", "com"} column 1 , {"inf", "ina"} column 2! getting error:

error 2 invalid rank specifier: expected ',' or ']' can help?

the issue cannot instantiate both dimensions of jagged array @ same time. that's because each array in array can have different length.

but it's easier linq

string[][] advlistkeys = key.split(',')                             .select(o => o.split('|'))                             .toarray(); 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -