How to set non-static variable in static method within class

2009-11-19 Thread Sam Hu
Greetings! How to set value to non-static variable in a static method within a class? Given below code: import std.stdio; class InputDialog { string name; static string s_name; static this() { s_name="";

Re: How to set non-static variable in static method within class

2009-11-19 Thread Ary Borenszweig
Sam Hu wrote: Greetings! How to set value to non-static variable in a static method within a class? Given below code: import std.stdio; class InputDialog { string name; static string s_name; static this() { s_name="";

Re: How to set non-static variable in static method within class

2009-11-19 Thread Sam Hu
Ary Borenszweig Wrote: > > You can't access non-static data from a static method. Non-static data > is related to an instance of a class, and a static method is not bound > to any instance. > > Why do you want to do that? Say I want to implement an utility dialog, InputDialog in DFL which is

Re: How to set non-static variable in static method within class

2009-11-19 Thread Trass3r
You can't access non-static data from a static method. Non-static data is related to an instance of a class, and a static method is not bound to any instance. Exactly. The only way would be to have some array of instances somewhere to access.

Re: How to set non-static variable in static method within class

2009-11-20 Thread Rory McGuire
Sam Hu wrote: > Ary Borenszweig Wrote: > >> >> You can't access non-static data from a static method. Non-static data >> is related to an instance of a class, and a static method is not bound >> to any instance. >> >> Why do you want to do that? > > Say I want to implement an utility dialo