我正在嘗試製作一個反轉C#文本的程序。我是C#的新手,我不太清楚如何做到這一點。我知道我必須從文本框中獲取輸入並將其轉換,但我不知道該怎麼做。我看到的一些網站是爲VB或已關閉。在C#中反轉文本#
我也想有另一個文本框顯示單詞的長度
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
textBox2.Text = textBox1.Text;
textBox3.Text = textBox1.Text + "4";
}
private void button2_Click(object sender, EventArgs e)
{
textBox2.Text = " ";
textBox3.Text = " ";
}
private void button3_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
我能找到這個代碼,但我不能確定如何使其適合與我
private void btnReverseString_Click(System.Object sender, System.EventArgs e)
{
string OriginalString = txtOriginalString.Text;
string ReverseString = "";
for (int i = 0; i <= OriginalString.Length - 1; i++)
{
ReverseString += OriginalString[OriginalString.Length - 1 - i];
}
txtReverseString.Text = ReverseString;
}
我同意它是重複的,我不投票關閉作爲愚蠢只因爲**沒有令人滿意的答案**在那篇文章中。如果其他人找到更好的投資,我會投票結束。 –