Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private void btnButton_Click(object sender, EventArgs e)
        {
            int array;

            string value = Interaction.InputBox("Enter array size", "Array Size");
            if (int.TryParse(value, out array))
            {
                string[] Names = new string[array];

                txtOutput.Text = "Unsorted array: \r\n";

                foreach (string name in Names)
                {
                    string prompt = Interaction.InputBox("Please enter a string" , "Enter Strings");
                    if (prompt == "")
                    {
                        txtOutput.Text += names +"\t";
                    }
                }
Posted
Comments
[no name] 23-Jun-14 10:37am    
http://www.dotnetperls.com/string-array

You can use string.Split() for that.
http://msdn.microsoft.com/en-us/library/system.string.split.aspx[^]

Good luck!
 
Share this answer
 
If you want to add the values from the InputBox to the array, then instead of a foreach loop, you can use a for loop.
C#
for (int i = 0; i < Names.Length; i++)
{
    string prompt = Interaction.InputBox("Please enter a string" , "Enter Strings");
    Names[i] = prompt;
    
    // your other code in the loop here
}
 
Share this answer
 
Comments
Member 10703465 23-Jun-14 10:48am    
Thank you so much. it works :)
Thomas Daniels 23-Jun-14 10:49am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900