How to get first five characters from a string in C#

1 Answer

0 votes
using System;
  
class Program
{
   static void Main() {
        string s = "c#-programming";
          
        string firstFive = s.Substring(0, 5);
  
        Console.WriteLine(firstFive);
    }
}
  
  
  
  
/*
run:
  
c#-pr
  
*/

 



answered Jun 8, 2021 by avibootz
edited Nov 13, 2021 by avibootz

Related questions

...