c# - How can I make each array, within an array perform a task? -


i getting data 1 of following names, adam, bob, cam, dan, earl, or fred.

i want pairs operate on each other. right have string:

string list="adam-bob;cam-dan;earl-fred"; 

then split them via semicolon

string[] splitlist=list.split(';'); 

now have array of pairs so

adam-bob cam-dan earl-fred    [0]     [1]      [2] 

ideally, perform operation on each of them, instead find can following: split via ','

foreach (string s in splitlist) { string firstperson=splitlist[0]; string secondperson=splitlilst[1];  if (udpoutputdata.contains(firstperson)==true) { //record data string firstperson }  if (udpoutputdata.contains(seoncdperson)==true) { //record data string secondperson }  //if have data firstperson , secondperson, perform operation , give me output } 

unfortunately, if name adam, followed cam, operations disorganized. perhaps need automatically create string each name? or there eloquent way of operating data on first array...

you array of arrays (of string), this:

string[][] splitlist = list.split(';').select(pair => pair.split('-')).toarray(); 

then can access splitlist[0][0] adam, splitlist[0][1] bob, splitlist[1][0] cam, etc.

so loop becomes:

foreach (string[] pair in splitlist) {     string firstperson=pair[0];     string secondperson=pair[1];      // ... 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -