How to use static function in web service?

M

Mark Ingram

Hi, how can I use a static function in a web service from a C# app?

I have the following code in a web service:

public class MyClass
{
[WebMethod]
public static Boolean Exists(String check)
{
return false;
}
}



Then in the C# app I try to use the web service:

MyClass.Exists("");

And I get an error saying Exists doesn't exist.



Can you not use static functions? Or am I doing something wrong?

Thanks
 
G

Guest

You can only apply [System.Web.Services.WebMethod()] attaribute to non static
methods, however you may use static members within webmethod i.e.

public class MyClass
{
[WebMethod]
public bool Exists(String check)
{
return InternalExists(check);
}

private static bool InternalExists(string check)
{
// TODO : implement
return false;
}


}

hope this helps
 

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

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top