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; } 


that's code return me output:
enter image description here

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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -