सबसे पहले, एक स्ट्रिंग सेट करें -
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