In this article we learn How to sort string Using array. It is more important project related to array. In this we can also learn how to use array.
<asp:Label ID="Label1" runat="server" Text="List of Unsorted name"></asp:Label>
<br />
<asp:TextBox ID="TextBox1" runat="server" Height="175px" TextMode="MultiLine"
Width="200px"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Sorted list" />
Now declare the array on Default.aspx.vb page.
{
string[] myArray = {
"Brijesh",
"Pooja",
"Manoj",
"Neha",
"Ankit"
};
Now write the following code on page load event //Message Displayed on your WebForm Label1.Text = "Unsorted Array List"; //Displays UnSorted list foreach (string arrayStr in myArray) { TextBox1.Text += arrayStr + Constants.vbCrLf; }
//Message Displayed on your WebForm Label1.Text = "Unsorted Array List"; //Displays UnSorted list foreach (string arrayStr in myArray) { TextBox1.Text += arrayStr + Constants.vbCrLf; }
//Message Displayed on your WebForm
Label1.Text = "Unsorted Array List";
//Displays UnSorted list
foreach (string arrayStr in myArray)
TextBox1.Text += arrayStr + Constants.vbCrLf;
}
Now use the following code on button cliick.
//Method that Sort the List
Array.Sort(myArray);
//Sets the Text to Null
TextBox1.Text = string.Empty;
//Displays the Sorted list
Label1.Text = "Sorted Array List";
Now run this application and you get a sorted result.End of this application. Output of This ApplicationPress the Sort list Button