빠른 메모 - 나는 매우 어리 석다.문자열의 문자를 다른 문자로 바꾸고 다시 전환하십시오.
책에서 간단한 C# 작업을 완료하는 데 어려움을 겪고 있습니다.
Pseudocode-
텍스트 상자 텍스트 = 버튼을 두 가 대체 클릭하면 버튼 하나를 별표 다른
와 텍스트 상자에 모두 대문자로 교체 을 클릭하면
사용자 입력 원래 문자가있는 별표 (정상으로 돌아 가기)
여기가 내가 가지고있는 것입니다.
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가 별표가있는 텍스트를 표시한다는 것입니다. 원래 캐릭터를 보여 주어야합니다.
감사 알렉산더! –