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#
string[] separatingStrings = { "<<", "..." };
string text = "one<<two......three<four";
System.Console.WriteLine($"Original text: '{text}'");
string[] words = text.Split(separatingStrings, System.StringSplitOptions.RemoveEmptyEntries);
System.Console.WriteLine($"{words.Length} substrings in text:");
foreach (var word in words)
{
System.Console.WriteLine(word);
}
แยกโดยใช้ข้อความ c#
//Split using a string delimiter instead of a char
data.Split(new string[] { "xx" }, StringSplitOptions.None);
วิธีที่จะแบ่งข้อความจากใน c#
char[] separator = new[] { ',' };
var result = aiTranslatedString.Split(separator, StringSplitOptions.RemoveEmptyEntries).ToList();