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

Sam Hu samhu.samhu at nospam.com
Thu Nov 19 04:41:58 PST 2009


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 a subclass of Form,using its static method I can call InputDialog.getString to retrieve a string from the textbox of this dialog  other than create an instance of InputDialog,at the mean time I want to customize the caption text and the prompt message of the InputDialog in the static method InputDialog.getString.But I can't modify Form.text, (form.)TextBox.text  in the static method.Currently I have to  use its non-static version of getString method and create an instance of the dialog each time when I call getString.


More information about the Digitalmars-d-learn mailing list