how to call static method?

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Hi,

I have an aspx file and it's cs file. I have another class
cs file which execute stored procedure.

In the class cs file, there are static methods.

But, the button event method in aspx.cs file is not static
type.

How can i use that static method in aspx.cs which is non-
static?
 
You just call the method, using the class name in place of the instance
name:

public class MyClass
{
public static void StaticDoit() { }
public void Doit() { }
}

// instance:
MyClass mc = new MyClass();
mc.Doit();

// static:
MyClass.StaticDoIt();

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top