0

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 ?

3
Contributors
6
Replies
8
Views
5 Years
Discussion Span
Last Post by thines01
0

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

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.

0

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;
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.