How to replace the first N characters in a string in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        string str = "pro csharp";
        
        int N = 3;
        str = "XYZ" + str.Substring(N);

        Console.WriteLine(str);
    }
}



/*
run:

XYZ csharp

*/

 



answered Jun 12, 2022 by avibootz

Related questions

1 answer 178 views
3 answers 261 views
1 answer 185 views
1 answer 140 views
1 answer 116 views
2 answers 150 views
1 answer 128 views
...