asp.net - How can i return array of object from web service with c#? -
i want write simple web service return user array object string c#,write code in server web service:
public string[] mymethod() { string [] mytemp=new string[10]; for(int i=0;i<10;i++){ mytemp[i]=i+1.tostring(); } return mytemp; }
but want return this:
<mymethodresult> <string> <name>user1</name> </string> <string> <name>user2</name> </string> <string> <name>user3</name> </string> </mymethodresult>
you can't return xml structure without informing web service type want return. need create class has [serializable] attribute , add properties resemble result you're expecting , class 1 return on web method. may refer microsoft link
Comments
Post a Comment