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 176 views
3 answers 261 views
1 answer 184 views
1 answer 140 views
1 answer 115 views
2 answers 149 views
1 answer 127 views
...