[WebMethod] doesn' work for properties in WebService

S

sunnyz

i am using property in Webservice.But [WebMethod] attribute doesn'
work for properties.Cud any1 tell me plz which attribute to use for
properties

thx

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
K

Kevin Spencer

Cud any1 tell me plz which attribute to use for
properties

I cud. None.

Web Services expose methods (behavior), not properties (state). However, as
a property can have a set and a get METHOD, you can certainly write
WebMethods that expose fields and properties. Example:

private string foo = "bar";

[WebMethod]
public string GetFoo()
{
return foo;
}

[WebMethod]
public string SetFoo(string value)
{
foo = value;
}

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

sunnyz said:
i am using property in Webservice.But [WebMethod] attribute doesn'
work for properties.Cud any1 tell me plz which attribute to use for
properties

thx

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 

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,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top