c# - Returning data from foreach data -


i trying return data foreach "hostedid" can help?

public static string gethostedrecordset() {     var request = new listhostedzonesrequest()     {         maxitems = "1"     };      var list = client.listhostedzones(request);      foreach (var hostedid in list.hostedzones)     {         console.writeline("\n hosted id is:");         console.write(hostedid.id);     }      return hostedid; } 

if want return values single string can concatenate them delimiter, such ',':

public static string gethostedrecordset() {     var request = new listhostedzonesrequest()     {         maxitems = "1"     };      var list = client.listhostedzones(request);      stringbuilder result = new stringbuilder();     foreach (var hostedid in list.hostedzones)     {         result.append(hostedid.id).append(",");     }      return result.tostring(0, math.max(0, result.length - 1); } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -