将值插入字符串中的某个位置? [英] Insert value into a string at a certain position?
本文介绍了将值插入字符串中的某个位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要在文本框中放置一个值,让它在字符串temp变量中的某个位置说 12。然后,我想在该值之后加上另一个值 10,但要在中间加上一个:,就像时间一样。
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 a : in between like a time. Both come from Text boxes and are validated so they can only be numbers.
推荐答案
您不能修改字符串;它们只能是数字。他们是一成不变的。您可以改为:
You can't modify strings; they're immutable. You can do this instead:
txtBox.Text = txtBox.Text.Substring(0, i) + "TEXT" + txtBox.Text.Substring(i);
这篇关于将值插入字符串中的某个位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文