i'm am trying to make a program that reverses text in C#. I'm am new to C# and am not quite sure how to do this. I know i have to get the input from the textbox and convert it but i don't know how to do that. Some of the websites i looked at are either for VB or have been closed.
i would also like to have another textbox display the length of the word
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();
}
}
}
I was able to find this code but am unsure how to make it fit with mine
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;
}