Contact: aviboots(AT)netvision.net.il
41,599 questions
54,241 answers
573 users
using System; class Program { static void Main() { string s = "c# javascript php c c++ python vb.net"; Console.Write(s.Substring(0, s.IndexOf(" "))); } } /* run: c# */
using System; class Program { static void Main() { string s = "c# javascript php c c++ python vb.net"; string first_word = s.IndexOf(" ") > -1 ? s.Substring(0, s.IndexOf(" ")) : s; Console.Write(first_word); } } /* run: c# */
using System; using System.Linq; class Program { static void Main() { string s = "c# javascript php c c++ python vb.net"; string first_word = s.Split(' ').First(); Console.Write(first_word); } } /* run: c# */
using System; class Program { static void Main() { string s = "c# javascript php c c++ python vb.net"; string first_word = s.Split(' ')[0]; Console.Write(first_word); } } /* run: c# */