Create List of strings from the string inputted by the user c# -


i have method:

public list<string> advmultikeysearch(string key) {     string[] listkeys = key.split(',');      string[] orsplit;     list<string> joineddashkeys = new list<string>();     list<string> joinedsearchkeys = new list<string>();      (int = 0; < listkeys.length; i++)     {         orsplit = listkeys[i].split('|');         joineddashkeys.add(string.join(",", orsplit));     }      (int = 0; < joineddashkeys.count; i++)     {         string[] split = joineddashkeys[i].split(',');         (int j = 0; j < split.length; j++)         {             joinedsearchkeys.add(string.join(",", split[i]));         }     }      return joineddashkeys; } 

i trying create method receives string keyword composed of words,comas, , '|' character. example, user enters

glu|sal,1368|1199

and method should produce/return list of strings: "glu,1368", "glu,1199", "sal,1368", "sal,1199"

it's been more 2 hours , still can't figure out how correctly implement it. can please?

given input above show number of combinations long there 1 comma.

char[] splitter1 = new char[] { '|' }; char[] splittercomma = new char[] { ',' }; public list<string> advmultikeysearch(string key) {     list<string> strings = new list<string>();      string[] commasplit = key.split(splittercomma);     string[] leftsidesplit = commasplit[0].split(splitter1);     string[] rightsidesplit = commasplit[1].split(splitter1);      (int l = 0; l < leftsidesplit.length; l++)     {         (int r = 0; r < rightsidesplit.length; r++)         {             strings.add(leftsidesplit[l] + "," + rightsidesplit[r]);         }     }      return strings; } 

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 -