I quite new to c# and asp.net so plz tell me if i give you to little info for my question.
When a user is logging in I create an instance of my User object, calling my getcategories method and the redirect then user to another page. Like this:
if (dt.Rows.Count > 0){
    user apa = new user();
    apa.namn = dt.Rows[0]["FirstName"].ToString() + " " + dt.Rows[0]["LastName"].ToString();
    apa.mail = dt.Rows[0]["Email"].ToString();
    apa.id = dt.Rows[0]["ID"].ToString();
    apa.firstname = dt.Rows[0]["FirstName"].ToString();
    apa.lastnamn = dt.Rows[0]["LastName"].ToString();
    apa.password = dt.Rows[0]["Password"].ToString();
    Session["user"] = apa;
    apa.getcategories();
    Response.Redirect("visainlagg.aspx");
}
The problem is that I get "object reference not set to an instance of an object"-error on "kategorier[i].Name = dt.Rows[i]["Name"].ToString();" (the first thing that happens in my for loop in User class). I do not understand why :(
This is how the User class looks like:
public string namn;
public string mail;
public string id;
public string firstname;
public string lastname;
public string password;
public string constr = "secret";
public Post[] poster;
public anvcateg[] kategorier;
public int antalKategorier;
public void getcategories() { 
    SqlConnection conn = new SqlConnection();
    conn.ConnectionString = constr;
    SqlCommand com = new SqlCommand();
    com.Connection = conn;
    com.CommandText = "SELECT * FROM Category WHERE Author= '" + id + "'";
    SqlDataAdapter adp = new SqlDataAdapter();
    adp.SelectCommand = com;
    DataTable dt = new DataTable();
    adp.Fill(dt);
    antalKategorier = dt.Rows.Count;
    kategorier = new anvcateg[dt.Rows.Count];
    for (int i = 0; i < dt.Rows.Count; i++)
    {
        kategorier[i].Name = dt.Rows[i]["Name"].ToString();
        kategorier[i].ID = dt.Rows[i]["ID"].ToString();
        kategorier[i].Description = dt.Rows[i]["Description"].ToString();
        kategorier[i].Author = dt.Rows[i]["Author"].ToString();
    } 
}
the anvcateg class that getcategories() is using looks like this:
public class anvcateg
{
    public string ID;
    public string Name;
    public string Description;
    public string Author;
 
     
     
     
    