c#我如何使它,所以当我键入只有星星

本文关键字:星星 何使它 | 更新日期: 2023-09-27 17:51:06

我基本上是用我自己做的一个程序,这是一个程序,需要一个密码来打开w/e应用程序,我已经分配了它了。但是我不知道如何使文本变成*而不是常规文本。这只是一个控制台程序。

c#我如何使它,所以当我键入只有星星

    //read from here
    private void Form1_Load(object sender, EventArgs e)
    {
        //changes whatever you type into your textbox to be an asterisk 
        textBox1.PasswordChar = '*'; 
    }
    private void textBox1_TextChanged(object sender, EventArgs e)
    {
          //ignore this method
    }
    private void button1_Click(object sender, EventArgs e)
    {
        //Just to validate that the text is what you want it to be
        string text = textBox1.Text;
        MessageBox.Show(text);
    }