How to get the first 5 characters of string in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        string str = "c# programming";

        Console.Write(str.Substring(0, 5));
    }
}




/*
run:

c# pr

*/

 



answered Aug 15, 2023 by avibootz

Related questions

1 answer 110 views
2 answers 174 views
1 answer 113 views
1 answer 123 views
1 answer 157 views
1 answer 130 views
2 answers 157 views
...