c# - Object reference not set to an instance of an object -


this question has answer here:

i had working yesterday must of changed listactivelogins.activelogins null, did do?

public partial class form1 : form {     public form1()     {         initializecomponent();         new listlogin(2);         console.writeline(listlogin.loginlist.length);         console.writeline(listlogin.loginc);         new listactivelogins(2);         console.writeline(listactivelogins.activelogins.length);     } }  public class listlogin {     public static int loginc;     public static string[,] loginlist;     public listlogin(int logincount)     {         loginlist = new string[logincount, 3];         loginc = logincount;     }     public int logincount     {         { return loginc; }     }     public string this[int row, int col]     {                 {             return loginlist[row, col];         }         set         {             loginlist[row, col] = value;         }     } }  public class listactivelogins {     public static process[] activelogins;     public listactivelogins(int logincount)     {         process[] activelogins = new process[logincount];     }     public process this[int i]     {                 {             return activelogins[i];         }         set         {             activelogins[i] = value;         }     } } 

the problem declared local variable in listactivelogins constructor.

this should fix it.

public class listactivelogins {     public static process[] activelogins;     public listactivelogins(int logincount)     {         activelogins = new process[logincount];     } 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -