How to replace part of string by position?

后端 未结 18 887
逝去的感伤
逝去的感伤 2020-11-28 04:37

I have this string: ABCDEFGHIJ

I need to replace from position 4 to position 5 with the string ZX

It will look like this: ABC

18条回答
  •  孤城傲影
    2020-11-28 05:26

    You could try something link this:

    string str = "ABCDEFGHIJ";
    str = str.Substring(0, 2) + "ZX" + str.Substring(5);
    

提交回复
热议问题