c# - How I get one variable argument from one method to another -


hy,

i have following constuctor:

 public partial class selectsize : form     {         public selectsize(string name)         {             this.name = name;             initializecomponent();         }          public string name         { get; set; } 

and want name use in following method:

p private void button1_click(object sender, eventargs e)     {          if (((int.parse(norows.text) % 2) == 0) && (((int.parse(nocols.text) % 2) == 0)) && ((int.parse(norows.text) ==             int.parse(nocols.text))) && ((int.parse(norows.text) > 6) && ((int.parse(norows.text) > 6))))         {             //string name = this.name;             playme f = new playme(int.parse(nocols.text), int.parse(nocols.text), name);             this.hide();             f.showdialog();             this.close(); 

but null reference name.

how transfer 1 variable method?

sincerly,

if this.name null different constructor has been called or null passed constructor. check on that. may, of course, have been overwritten in meantime. e.g. our point of view. don't know of code, this.name = null; in instanciatecomponent().

well, happen both methods not executed on same (identical) instance of class. compare ojbjects' addresses if equal.

btw, should call this.name rather this.name , instanciatecomponent() should instanciatecomponent().


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -