I do not understand eventhou I can show the values by console.writeline but it throws null exception error.
class Collection{
static string[] user_array;
static string[] user_password;
static string username;
static string password;
public void register(){
Console.WriteLine("Enter member's username");
username = Console.ReadLine();
Console.WriteLine("Enter member's password?(4 digits)");
password = Console.ReadLine();
}
public string[] getUsername() {
for (int i = 0; i < counter; i++) {
user_array[i] = Member.Username[i]; //////I get null exception
}
return user_array;
}
public string[] getUserpassword() {
for (int i = 0; i < counter; i++)
{
user_array[i] = Member.Password[i]; //////I get null exception
}
return user_password;
}
public void showMember()
{
for (int i = 0; i < counter; i++) {
Console.WriteLine("");
Console.WriteLine(Member.Username[i]);
Console.WriteLine(Member.Password[i]);
Console.WriteLine(Member.Phonenum[i]);
}
}
}
Even though I can show values of Member.username[i] and Member.password[i] using console.writeline, I keep getting null exception when I try to store those value into a new array And this is my Member class
class Member{
static public string[] FirstName = new string[100];
static public string[] LastName = new string[100];
static public string[] Address = new string[100];
static public string[] Phonenum = new string[100];
static public string[] Password = new string[100];
static public string[] Username = new string[100];
static public int[] Borrowedmovie = new int[100];
public Member(){
}
}