Monday, June 28, 2004

 

Call to Static Methods








Call to Static Methods

You cannot call static method of a class using the object of the class...
You would have to call it using the Class name itself..
eg.You cannot call base class's static method using base.StaticMethod();
that shall result into an error...

the way you do it is:
//Class having Static Method
public class MyClass
{
public static string StaticMethod()
{
return "miteshvmehta@gmail.com";
}
}

//Class using Static Method
public class ClientClass
{
public string GetHelpLineEmailId()
{
return MyClass.StaticMethod();
}
}

Mitesh Mehta
Microsoft Certified Professional .Net
If You Think YOU CAN... You Can...





Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?