Advertisement
AalborgHTX

DoWhile løkker

Jan 28th, 2021
622
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApp22
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         private void btnDo_Click(object sender, EventArgs e)
  21.         {
  22.             int a = int.Parse(txtTælOpTil.Text);
  23.             int i = 0;
  24.  
  25.             do
  26.             {
  27.                 lstDo.Items.Add(i.ToString());
  28.                 i = i + 1;
  29.  
  30.             } while (i<a);
  31.  
  32.         }
  33.  
  34.         private void btnWhile_Click(object sender, EventArgs e)
  35.         {
  36.             int a = int.Parse(txtTælOpTil.Text);
  37.             int i = 0;
  38.  
  39.             while (i<a)
  40.             {
  41.                 lstWhile.Items.Add(i.ToString());
  42.                 i = i + 1;
  43.             }
  44.  
  45.         }
  46.     }
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement