-2

Hey guys I have a quick question. I am trying to parse a single string into multiple strings using a keyword. I can currently find a set of code that allows me to parse the single string but I need to store each of the new strings as a new variable/item.

string full = "Hey//Please//Help";

parse into:

first string- Hey

Second string- Please

third string- Help

So for example I would like to manipulate the first string, Hey, by itself. Please let me know if any more explanation is necessary.

asdfsa
  • 1

1 Answers1

1

Simple String.Split:

string[] results = full.Split(new string[] { "//" }, StringSplitOptions.RemoveEmptyEntries);

foreach(string str in results)
{
    Console.WriteLine(str);
}

Result:

Hey
Please
Help
Zein Makki
  • 29,485
  • 6
  • 52
  • 63
  • @un-lucky You could have just noted that out in a comment instead of down-voting the whole answer, while it generated the excepted result needed by the user – Zein Makki Jun 22 '16 at 14:34
  • 2
    @un-lucky these are (imho) no down-vote reasons, the space is no syntactical problem, neither the superfluos `@`. The answer is correct and well explaining, I don't see a reason to downvote. – René Vogt Jun 22 '16 at 14:34
  • @RenéVogt: You may look after edit, I just down-voted to let him modify the answer. Now it is Fine and perfect answer. – sujith karivelil Jun 22 '16 at 14:37