c# - Can't Set variable value in Static Field -
in simple example why stra
in sample()
function can't set "hi world" string ?
string stra { get; set; } private void button1(object sender, eventargs e) { stra = "hi world"; //=======> stra value } public static string sample() { myclass myclass1 = new myclass(); string = myclass1.stra; //==========> can't set stra value "hi world" string ??? return (messagebox.show(a).tostring()); }
make stra static field, right it's local property of instance, when create new instance myclass1 = new myclass();
the stra property empty (null) , if set value, after create new instance new instance have srta empty...
Comments
Post a Comment