How to remove the first word from a string in C#

1 Answer

0 votes
using System;
 
class Program
{
    static void Main() {
        string s = "c++ c c# java python";   
         
        if (s.Length > 0) {
            int i = s.IndexOf(" ") + 1;
            s = s.Substring(i);
        }
 
        Console.Write(s);
    }
}
 
 
 
/*
run:
 
c c# java python
 
*/

 



answered Jun 20, 2022 by avibootz

Related questions

1 answer 141 views
3 answers 256 views
4 answers 289 views
4 answers 322 views
1 answer 120 views
1 answer 95 views
...