Click here to Skip to main content
16,018,418 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
hi can i use class as datatypes in asp.net web services.
class person
{
string username;
string age;
string address;
}
[webmethod]
public void test(person p)
{

}
Posted
Updated 8-Jan-14 22:52pm
v2

 
Share this answer
 
yes you can do it..
here the sample:

C#
public class Service1 : System.Web.Services.WebService
   {

       [WebMethod]
       public person GetPerson()
       {
           return new person() {username ="some" , address ="add",age = 25   };
       }

       [WebMethod]
       public void passPersonToDosomeAction(person p)
       {
           string addres = p.address;
           // do something
       }
   }

 public  class person
   {

       public string username { get; set; }
       public int age { get; set; }
       public string address { get; set; }

   }
 
Share this answer
 
Making the container class public should be enough. The framework will take care of the rest.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900