Reputation: 187
I want to write a text like this in the text box: "Sentence1::Sentence2::Sentence3" and Then separate it to three parts and put them in three separately strings. I used string.split method but I couldn't put them to strings.
string authors = "Sentence1::Sentence2::Sentence3";
string[] authorsList = authors.Split("::");
Upvotes: 0
Views: 528
Reputation: 39152
You have an ARRAY of Strings after the Split(). You access the strings by index. Here's an example:
string authors = "Sentence1::Sentence2::Sentence3";
string[] authorsList = authors.Split("::");
for(int i=0; i<authorsList.Length; i++) {
Console.WriteLine(i + ": " + authorsList[i]);
}
Output:
0: Sentence1
1: Sentence2
2: Sentence3
Upvotes: 2