簡単なメモ - 私は c# に非常に慣れていないので、これがばかげて単純である場合は申し訳ありません。
本で簡単な C# タスクを完了するのに苦労しています。
疑似コード-
テキスト ボックスのテキスト = ユーザー入力
ボタン 1 がクリックされた場合、テキスト ボックス内のすべての大文字をアスタリスクに置き換えます
ボタン2がクリックされた場合は、アスタリスクを元の文字に置き換えます(通常に戻ります)
これが私がこれまでに持っているものです
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);
}
}
}
}
問題は、button2 がアスタリスク付きのテキストを表示していることです。元のキャラクターを表示する必要があります(表示したい)。