Ciao ragazzi, mi sto perdendo in un bicchiere d'acqua.... ho questa semplice classe:
public class prova
{
private int myVar;
public int MyProperty
{
get { return myVar; }
set { myVar = value; }
}
private ArrayList _toolBoxControls;
public ArrayList ToolBoxControls
{
get { return _toolBoxControls; }
set { _toolBoxControls = value; }
}
public prova()
{
this.MyProperty = 1; // qui nessun errore
string b = "test";
this.ToolBoxControls.Add(b); // qui Errore: Object reference not set to an instance of an object
}
}
come mai? Devo impostare un valore iniziale per la proprietà ToolBoxControls? E se sì, come?
P.S. Le proprietà di tipo string hanno un valore iniziale di default?
![]()

Rispondi quotando