去掉 [英] remove
本文介绍了去掉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想删除字符串中的最后一个字符,对吗?
I would like to remove the last char in a string is thiis right?
私有 无效 backspace()
private void backspace()
{
int g;
int g;
g = KeyBoard_textBox.Text.Length;
g = KeyBoard_textBox.Text.Length ;
KeyBoard_textBox.Text.Remove(g,0);
KeyBoard_textBox.Text.Remove(g, 0);
}
推荐答案
为什么不直接测试呢?
Why don't you just test it?
他
但是我很确定它应该是KeyBoard_textBox.Text.Remove(g -1,1);
but i am pretty sure it should be KeyBoard_textBox.Text.Remove(g -1, 1);
您正在获取字符串的长度.现在,字符串是从0开始索引的,如果将g用作索引,则可能会导致您溢出异常.
You are getting the length of the string. Now strings are 0-indexed, if you'd put g as the index it would maybe ge you an overflow exception.
享受:)
这篇关于去掉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文