Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to directly access class methods?
Message
 
À
19/06/2002 02:27:32
Czarina Joyce Villanueva
Innovision Systems International
Manila, Philippines
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00670022
Message ID:
00670031
Vues:
15
>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()
{
...
}
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform