John  Burns

John Burns

  • NA
  • 120
  • 109.3k

why wont C#do this simple action?

Dec 13 2010 2:21 PM
i setup a simple loop and wanted a window to appear showing the results of the loop .. it fails, but works perfeclty fine in VB!

   private void button1_Click(object sender, EventArgs e)
        {
            int count = 10;
            while (count > 5)
            {
                count = count - 1;
                MessageBox.Show(count);
            }

made small amendment. says it cant convert from int to string

however it will work with string, like this:

 private void button1_Click(object sender, EventArgs e)
        {
           string count = "john";
           
            {
                MessageBox.Show(count);
              
            }

so somethings telling me VB has one over C# on that simple action. so i gota figure a way out of formatting that integer value to a string i guess in order to show it in the textbox but even the ToString method fails to work .. hmmmmm

Answers (12)