How to return a list using string array method ? For eg. i want to display a list of all the estates name using string array ?

Recommended Answers

All 6 Replies

Try to do this way:

string[] arrString = { "a", "b", "c" };  
List<String> lstString = new List<string>(arrString);

when your method needs to retun a List<T> then you do:

//......
private List<string> GetData()
{
   string[] arrString = { "a", "b", "c" };  
   return new List<string<(arrString);
}

What do you mean?

for example; i want to GetEstatesName. The result have to be like a list of the whole estates name using the string array method. May i know how do i type it in the IService.cs and IService.svc.cs so that when i test in the web browser, the whole list of estates will appear. Thanks.

If the answer to the last question is yes, then you will need to add (to your WCF IService file)

[OperationContract]
List<string> GetUsStates();

...and to your Service.svc.cs (or another code file):

public List<string> GetUsStates()
{
   List<string> lst_strReturn = new List<string>();
   //... parse the data and fill the list
   return lst_strReturn;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.