c#小问题
private void button1_Click(object sender, EventArgs e)
{
string Str1 = textBox1.Text;
char first = Str1[0]; //第一个字母
string Surplus = Str1.Substring(1); //剩下的字母个数
textBox1.Text = Surplus + first;
}
但是。我要的是在一个字符串里。没按一下按钮,从最后一个字符,移动第一位字符,其他的字符也跟着向右移动
[解决办法]
我是这样理解你的意思的:
假设字符串是Hello,点击一次后变成oHell,再点击变成loHel。即最后一个字符每次右移一位,补到最左边。
void btn_Click(object sender, RoutedEventArgs e) { string text = textBox1.Text; char last = text[text.Length - 1]; string other = text.Substring(0, text.Length - 1); this.defaultTextBlock.Text = last + other; }
[解决办法]
有一行没有改过来
void btn_Click(object sender, RoutedEventArgs e) { string text = textBox1.Text; char last = text[text.Length - 1]; string other = text.Substring(0, text.Length - 1); [color=#FF0000]textBox1.Text = last + other;[/color] }
[解决办法]
textBox1.Text = textBox1.Text.SubString(1) + textBox1.Text.SubString(0, 1);
[解决办法]