How to get substring of a string in C#

1 Answer

0 votes
using System;
 
class Program
{
    static void Main() {
        string s = "c# c c++ vb.net java python";  
         
        int startIndex = 3;    
        int endIndex = 8;    
         
        endIndex = endIndex - startIndex;    
         
        string substring = s.Substring(startIndex, endIndex);    
        Console.WriteLine(substring);
    }
}
 
 
 
 
/*
run:
 
c c++
 
*/

 



answered Jun 8, 2021 by avibootz

Related questions

1 answer 95 views
1 answer 112 views
112 views asked Oct 30, 2022 by avibootz
1 answer 107 views
107 views asked Oct 30, 2022 by avibootz
1 answer 166 views
1 answer 199 views
...