相同的命名空間:2種形式。錯誤C#中的字符串列表#
public class Account //frm1
{
public string Username;
public string Password;
}
public class ListAcc
{
public static List<Account> UserList;
}
private void button1_Click(object sender, EventArgs e)
{
List<Account> UserList = new List<Account>();
Account acc = new Account();
acc.Username = textBox1.Text;
acc.Password = textBox2.Text;
UserList.Add(acc);
}
private void button2_Click(object sender, EventArgs e) //frm2
{
string p = frmDangky.ListAcc.UserList[0].Username; // null ->error
string p = frmDangky.ListAcc.UserList[0].Password; // null ->error
}
有人能幫我嗎? :(爲什麼我的字符串爲NULL ????????文本框是不是空的...謝謝!