C# foreach loop between 2 values -


How can I use a foreach statement to loop between the 2 values ​​given by the user Am I

I am creating an application that scans for ports, so I want to specify the user which port to find; Here are some example codes that do not work, but you should help understand what I'm looking for:

  int port1 = Int32.Parse (TextBox1.Text); Int port2 = Int32.Parse (Textbox2.Text); Foreach (int between port1 and port2) {// do something}  

Any suggestions on how I can do this? No, the foreach for iterate over a collection is for the loop that you want.

  int port1 = Int32.Parse (Textbox1.Text); Int port2 = Int32.Parse (Textbox2.Text); (Var i = port1; i & lt; = port2; i ++) {// something}  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -