Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • 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

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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