namespace the_eighth{ public class program { static void Main() { File.Create("a.txt"); File.Create("b.txt"); string[] u = { "lzy", "lks" }; string[] p = { "199910", "199904" }; File.WriteAllLines("a.txt", u); File.WriteAllLines("b.txt", p); } } public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { String name = this.textBox1.Text; String passward = this.textBox2.Text; string[] user = File.ReadAllLines("a.txt"); string[] passwd = File.ReadAllLines("b.txt"); if (name ==user[0] && passward ==passwd[0]) { MessageBox.Show("登錄成功"); } else if(name==user[1]&&passward==passwd[1]) { MessageBox.Show("登錄成功"); } else { MessageBox.Show("用戶名或密碼錯誤!"); } } private void button2_Click(object sender, EventArgs e) { this.Close(); } }}
uj5u.com熱心網友回復:
namespace the_eighth
{
public class program
{
static void Main()
{
File.Create("a.txt");
File.Create("b.txt");
string[] u = { "lzy", "lks" };
string[] p = { "199910", "199904" };
File.WriteAllLines("a.txt", u);
File.WriteAllLines("b.txt", p);
}
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}