Ahoj,
proč když chci uložit do proměnné row[] dva řádky, které jsou v textovém dokumentu tak mi to napíše tuto chybovou hlášku? Index was outside the bounds of the array.
private string name;
private string password;
private string[] row;
public bool result;
public UserLogin(string nm, string pw)
{
this.name = nm;
this.password = pw;
row = new string[2];
Check();
}
private void Check()
{
FileStream fs = new FileStream("users.TXT", FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs, Encoding.UTF8);
int i = 0;
while (sr != null)
{
row[i++] = sr.ReadLine();
}
sr.Close();
if (name == row[0])
{
if (password == row[1])
{
result = true;
}
else result = false;
}
}
public bool Result
{
get
{
return result;
}
}