C#แยกฟังก์ชัน

รหัสตัวอย่าง

26
0

c คมแยกข้อความ

// To split a string use 'Split()', you can choose where to split
string text = "Hello World!"
string[] textSplit = text.Split(" ");
// Output:
// ["Hello", "World!"]
9
0

แยกข้อความใน 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}>");
}
5
0

c#แยกออกเป็นข้อความและกลับมารายชื่อ

listStrLineElements = line.Split(',').ToList();
5
0

วิธีที่จะแบ่งข้อความกับเชือกใน 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);
}
1
0

ข้อความแยก 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!]  
-2
0

ข้อความแยกออก c#

char[] delimiterChars = { ' ', ',', '.', ':', '\t' };

string text = "one\ttwo three:four,five six seven";
System.Console.WriteLine($"Original text: '{text}'");

string[] words = text.Split(delimiterChars);
System.Console.WriteLine($"{words.Length} words in text:");

foreach (var word in words)
{
    System.Console.WriteLine($"<{word}>");
}

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................