>Hi,
>
>I created a simple project with one Windows form. Then I added a class (Class1.cs) to this project. In the Class1.cs I created a couple of methods (one method is public).
>
>Then I try to call a method of the class in Class1.cs from Click method of the form. In the Form1.cs I added
>using myClass1NameSpace;
>
>But when I enter (in the form button Click() method) something like MyClassName. the intellisense does not show the public method in the class MyClassName. And when I enter this method anyway, I get error "An object reference is required for the nonstatic field, method, or property".
>
>What am I missing?
>
>TIA.
Did you define the method as static? If the method is static, you can call it as MyClassName.MyMethodName. If the method is not static, you first need to create an instance of the class to call its methods.
In other words,
MyClassName myclassobject = new MyClassName();
myValue = myclassobject.MyMethod(...);
If it's not broken, fix it until it is.
My Blog