How to get a substring from start string to specific character in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        string s = "c# c++ c vb.net java python";  

        string subs = s.Substring(0, s.IndexOf("a"));   
        Console.WriteLine(subs);
    }
}




/*
run:

c# c++ c vb.net j

*/

 



answered Feb 24, 2021 by avibootz

Related questions

...