How to generate string array in ASP.NET

Generate string array in ASP.NET

Below ASP.NET Example code will show how to create the string array using ASP.NET.

ASP.NET Code:

<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void CreateStringArray_Click(object sender, EventArgs e) { string[] countries = { "India", "US", "UK", "German" }; foreach (string country in countries) { lblStringArrayData.Text = lblStringArrayData.Text+country + "<BR />"; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <b>ASPNETTUTORIALONLINE.BLOGSPOT.COM</b><br /> <asp:button ID="btnCreateStringArray" runat="server" text="Create String Array and get values" onclick="CreateStringArray_Click" /><br /> <asp:Label ID="lblStringArrayData" runat="server"></asp:Label> </div> </form> </body> </html> 

Output:



Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar