Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 355
  • Last Modified:

VB.net C# simple for Next loop

Hi

Is there a more simple way to do the following For Next Loop in C#

public void A()
{
      int i = 0;
      for (i = 1; i <= 10; i++) {
            Interaction.MsgBox(Convert.ToString(i));
      }
}

I got this from converting the following VB.net code which looks far more simple

    Sub A()
        Dim i As Integer
        For i = 1 To 10
            MsgBox(CStr(i))
        Next i
    End Sub
0
Murray Brown
Asked:
Murray Brown
1 Solution
 
James AtkinSenior Principle Software EngineerCommented:
Hi,

Depends exactly what you are after...

You could use

for (int i = 1; i <= 10; i++) MessageBox.Show(i.ToString());
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now