सबसे पहले, एक स्ट्रिंग सेट करें:
string str = "Science and Mathematics";
अब Split() मेथड का उपयोग करें और जहां भी स्पेस हो वहां विभाजित करें:
str.Split(' ')निम्नलिखित पूरा कोड है:
उदाहरण
using System; using System.Linq; using System.IO; class Program { static void Main() { string str = "Science and Mathematics"; Console.WriteLine("स्ट्रिंग...\n"+str); string[] myStr = str.Split(' '); Console.WriteLine("\nविभाजित स्ट्रिंग..."); foreach (string ch in myStr) { Console.WriteLine(ch); } } }आउटपुट
स्ट्रिंग... Science and Mathematics विभाजित स्ट्रिंग... Science and Mathematics