প্রথমত, একটি স্ট্রিং সেট করুন -
string str = "Science and Mathematics";
এখন স্প্লিট() মেথড ব্যবহার করুন যেখানেই স্পেস আছে −
বিভক্ত করতেstr.Split(' ') নিম্নলিখিত সম্পূর্ণ কোড -
উদাহরণ
using System;
using System.Linq;
using System.IO;
class Program {
static void Main() {
string str = "Science and Mathematics";
Console.WriteLine("String...\n"+str);
string[] myStr = str.Split(' ');
Console.WriteLine("\nSplitted String...");
foreach (string ch in myStr) {
Console.WriteLine(ch);
}
}
} আউটপুট
String... Science and Mathematics Splitted String... Science and Mathematics