English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

see, if i have more than two classes other than main class how should i call it in main func (or) class without creating an object?

2007-03-08 17:05:13 · 3 answers · asked by sp 1 in Computers & Internet Programming & Design

3 answers

If the method of your class is static, you can invoke it directly by calling classname.Method(); otherwise you will need to instantiate the class.

2007-03-08 17:10:24 · answer #1 · answered by Rex M 6 · 0 0

Through using static classes or static methods. Following an example of how you do it:
public static class Utilities
{

public static void MyMethod()
{
// do stuff here

}
}
// --- calling the method.
Utilities.MyMethod();

2007-03-09 03:47:31 · answer #2 · answered by Smutty 6 · 0 0

you can only do this with a static class. if you do not declare it static, you cannot access its members without instantiating.

2007-03-09 01:11:57 · answer #3 · answered by shawntolidano 3 · 0 1

fedest.com, questions and answers