Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to directly access class methods?
Message
 
To
19/06/2002 02:27:32
Czarina Joyce Villanueva
Innovision Systems International
Manila, Philippines
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00670022
Message ID:
00670031
Views:
16
>I created class library and after compiling it, I want to access or use it in other projects. I successfully attached the class dll in my project but why is it that everytime I want to use the method properties I need to create new instance of the class?
>
>MyClassMethod myClsMethod = new MyClassMethod();
>int var1 = myClsMethod.GetTotalTax();
>
>I've seen VFPToolkit source code but using it is very easy. There is no need to create new instance of the class. Why?
>
>TIA


To use a method of a class without having an instance is called a static method.

These methods will not work on instances of a class, and hold any information across the class itself, not the instances of a class.

According to the C# book infront of me, you use the static keyword in the method/property line.
ie

public static int GetTotalTax()
{
...
}
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform