Quick note - I am very new to c# so I apologize if this is stupid simple.
I am having a hard time trying to complete a simple c# task in a book.
Pseudocode-
Text box text = user input
if button one is clicked replace all capital letters in the text box with an asterisk
else if button two is clicked replace the asterisks with their original characters (back to normal)
Here is what I have so far
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Text.RegularExpressions;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
button1.Click += new System.EventHandler(ClickedButton);
button2.Click += new System.EventHandler(ClickedButton);
}
private void Form1_Load(object sender, EventArgs e)
{
}
public void ClickedButton(object sender, EventArgs e)
{
string orignalText = textBox1.Text;
if (sender == button1)
{
string replaced = Regex.Replace(orignalText, @"[A-Z]", "*");
textBox1.Text = (replaced);
}
else if (sender == button2)
{
textBox1.Text = (orignalText);
}
}
}
}
The problem is that button2 is showing the text with the asterisks. It should be showing (I want it to show) the original characters.