Please I am facing a problem while accessing a function within a class inside a namespace in C#.
The format that i know is as follows: namespace.classname.functionname();
However, the above method is reporting for me the following error:
An object reference is required for the non-static field, method or property "namespace.classname.functionname()".
You need to declare an instance of the Class that contains the function
namespace.classname YourClass = new namespace.classname();
then you can use the function as follows
YourClass.functionname();
If you want to be able to use the function without declaring an instance of the class it needs to be a static funciton.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With