-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.

0

1 Answer 1

1

Simple String.Split:

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

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

Result:

Hey
Please
Help
Sign up to request clarification or add additional context in comments.

3 Comments

@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
@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: You may look after edit, I just down-voted to let him modify the answer. Now it is Fine and perfect answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.