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 153 views
3 answers 251 views
1 answer 173 views
1 answer 129 views
1 answer 101 views
2 answers 134 views
1 answer 116 views
...