So i try to get around this issue. I know for a fact that this will be initialized before am calling it but c# can not know this i guess. I cannot do xUser user = new xUser; One work around i was thinking about was using an List and store the values in list and then create the xuser after the while loop but it seems very messy. And i really wanna learn how to avoid this kind of errors.
noUSer iuser = new noUSer();
xUser user;
string sql = "select * from accounts where id='" +id +"'";
SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
SQLiteDataReader reader = command.ExecuteReader();
while (reader.Read())
{
iuser.user_name = reader["login"].ToString();
iuser.password = reader["password"].ToString();
iuser.cookie_file = @"c:\cookies";
user = iusers.create(iguser);
}
m_dbConnection.Close();
if (tab_mode.SelectedTab.Text == "User")
{
dothiscall(user); //Error on "user" local variable might be not initialized before accessing
}