textBox1.Text.Insert(…) method doesn't work

后端 未结 2 1198
太阳男子
太阳男子 2021-01-22 12:26

I\'m facing this abnormal situation. The following code doesn\'t work properly:

        string temp = \"heythere\";
        Console.WriteLine(temp);
        temp         


        
相关标签:
2条回答
  • 2021-01-22 13:23

    Strings are immutable, they don't change in-place. Try:

    string temp = "heythere";
    Console.WriteLine(temp);
    temp = temp.Insert(3, "hello");
    Console.WriteLine(temp);
    
    0 讨论(0)
  • 2021-01-22 13:25

    Or, your can try this

    string temp = "heythere";
    Console.WriteLine(temp.Insert(3, "hello"));
    
    0 讨论(0)
提交回复
热议问题