c# - class properties -



i've began using classes , make functions of class visible outside class. problem haven't got (and unable have) variable of type abc.
let me explain snippet of code:

class abc {     private float foo;     public float foo {         { return foo; }         set { foo = value; }     }      public static void hello() {         foo = 5.0f;         console.writeline("hello everyone!");     } }  .... somewhere else ....  abc bar; bar.foo = 5.0f;       // ok, know bar.hello();          // fine, know  abc.hello();          // i'm trying this! 

edit:
ok, suppose assign foo in hello (as in code). know might sound nonsense, i'm not sure it's possible.

you need static member function. static member functions not associated particular instance of class, need if want access them via class itself. specifics vary depending on whether you're interested in c++ or c#.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -