Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6336269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:01:27+00:00 2026-05-24T19:01:27+00:00

I’m making a menu type of all kinds of sorting algorithm. the user will

  • 0

I’m making a menu type of all kinds of sorting algorithm. the user will input ten numbers in the TextBox, select a RadioButton, then click the generate button. the output must show each line on how the algorithm works.

(Selection Sort)

sample input from TextBox: 9 6 8 7 5 2 3 1 10 4

output:

1 6 8 7 5 2 3 9 10 4 \n
1 2 8 7 5 6 3 9 10 4 \n
1 2 3 7 5 6 8 9 10 4 \n
1 2 3 4 5 6 8 9 10 7 \n
1 2 3 4 5 6 7 9 10 8 \n
1 2 3 4 5 6 7 8 10 9 \n
1 2 3 4 5 6 7 8 9 10 \n

I made a program like these on Java, but I only used JOptionPane. I do not have any ideas on how to convert it to c# and by using TextBox and RichTextBox.

Here’s my codes so far. My output always show a lot of zeros.

   int[] nums = new int[10]; 
   int i, s, min, temp;

   private void EnterNum_TextChanged(object sender, EventArgs e)
   {
       string[] nums = EnterNum.Text.Split(' '); 
       //int[] nums = new int[] { int.Parse(EnterNum.Text) };
   } 

   private void GenerateButton_Click(object sender, EventArgs e)
   {
       if (SelectionRadio.Checked == true)
       {
           for (i = 0; i < nums.Length - 1; i++)
           {
               min = i; 
               // In each iteration, find the smallest number
               for (s = i + 1; s < nums.Length; s++)
               {
                   if (nums[min] > nums[s])
                   {
                       min = s;
                   }
               }
               if (min != i)
               {
                   temp = nums[i];
                   nums[i] = nums[min];
                   nums[min] = temp;
               }
               Display();
           }
       }
       Display();
   }

   private void ClearButton_Click(object sender, EventArgs e)
   {  
       richTextBox1.Clear();
   }

   public void Display()
   {
       int i;
       String numbers = "";
       for (i = 0; i < 10; i++)
         numbers += Convert.ToInt32(nums[i]).ToString() + " ";
       richTextBox1.AppendText(numbers);
   }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:01:28+00:00Added an answer on May 24, 2026 at 7:01 pm

    before starting algorithm you need to fill your nums array from textbox, you see zeros because by default array is filled with zeros and you just displaying default array:

    string[] numsInString = EnterNum.Text.Split(' ');
    nums = new int[numsInString.Length];
    for (int j = 0; j < numsInString.Length; j++)
    {
        nums[j] = int.Parse(numsInString[j]);
    }  
    if (SelectionRadio.Checked == true)
    //...
    

    and to display nicely add “\n” when appending text:

    richTextBox1.AppendText(numbers+"\n");
    

    also as Matt mentioned use .ToString(), your nums are integers already so you dont need to convert int to int:

    numbers += nums[i].ToString() + " ";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I need a function that will clean a strings' special characters. I do NOT
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.