Insert value into a string at a certain position?

后端 未结 4 1185
我在风中等你
我在风中等你 2020-12-05 17:25

i\'m looking to place a value from a text box lets say \"12\" to a certain place in a string temp variable. Then I want to place another value after that say \"10\" but with

4条回答
  •  囚心锁ツ
    2020-12-05 17:36

    If you just want to insert a value at a certain position in a string, you can use the String.Insert method:

    public string Insert(int startIndex, string value)
    

    Example:

    "abc".Insert(2, "XYZ") == "abXYZc"
    

提交回复
热议问题