
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string str = textBox1.Text;
char first = str[0];
string surplus = str.Substring(1);
textBox1.Text = surplus + first;
}
private void button2_Click(object sender, EventArgs e)
{
string str = textBox1.Text;
int i = str.Length-1;
char first = str[i];
string surplus = str.Substring(0,i);
textBox1.Text = first + surplus;
}
}
}
本文介绍了一个使用C#实现的字符串操作方法,包括将字符串首字符移动到末尾和末字符移动到开头的功能。通过两个按钮点击事件触发,分别演示了如何进行字符串的重组。这个示例适用于初学者理解C#中字符串和字符的处理方式。

被折叠的 条评论
为什么被折叠?



