c คมแยกข้อความ
// To split a string use 'Split()', you can choose where to split
string text = "Hello World!"
string[] textSplit = text.Split(" ");
// Output:
// ["Hello", "World!"]
แยกข้อความใน c#
string phrase = "The quick brown fox jumps over the lazy dog.";
string[] words = phrase.Split(' ');
foreach (var word in words)
{
System.Console.WriteLine($"<{word}>");
}
c#แยกออกเป็นข้อความและกลับมารายชื่อ
listStrLineElements = line.Split(',').ToList();
แยกโดยใช้ข้อความ c#
//Split using a string delimiter instead of a char
data.Split(new string[] { "xx" }, StringSplitOptions.None);
ข้อความแยก c#
//splitting a string to a string[] (array)
string toSplit = "I Hope this will help YOU!";
string[] Splitted = toSplit.Split(' '); // ' ' NOT " "
//this is beacuse "" indicates a string but not a character literal(its '')
//OUTPUTS: [I, Hope, this, will, help, YOU!]
c#แยกข้อความ
string sentence = "Hello Beautiful World";
string[] words = sentence.Split(' ');
foreach (string word in words) {
print(word);
}