class Myclass
{
static string[] user_Name = { "admin", "user1", "user2" };
static string[] user_Password ={ "admin", "123", "789" };
public static void Check_Method(string u_name, string u_password)
{
for (int i = 0; i < user_Name.Length; i++)
{
if (u_name == user_Name[i] && u_password == user_Password[i])
{
MessageBox.Show("login successful");
break;
}
else
{
if (i == (user_Name.Length - 1))
MessageBox.Show("Badshow");
}
}
}
public static void add_user(string name, string password)
{
i=user_Name.Length;
user_Name[i]=name;
user_Password[i]=password;
//here i want to add another user but im unable to find the way
}
}
但它给出了一个错误,即它超出了数组的边界。
执行此操作最方便的方法是什么?