Aşağıda for döngüsü kullanılarak yapılmış asp.net uygulamalarının ekran görüntüleri bulun..
1-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | public void A( int a) { listBox1.Items.Add(a); if (a < 5) { A(++a); } } private void button1_Click( object sender, EventArgs e) { A(0); } |
1 2 3 4 5 6 7 8 9 10 11 | private void button1_Click( object sender, EventArgs e) { string [] names ={ "Ali" , "Oya" , "Can" , "Cem" }; foreach ( string value in names) { listBox1.Items.Add(String.Format("{0} -{1}",value.Substring(0,1),value)); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | protected void Button1_Click( object sender, EventArgs e) { ListBox1.Items.Clear(); Random numbers = new Random(); int [] array = { 1, 2, 3, 4, 5}; for ( int i = array.Length; i > 1; i--) { int j = numbers.Next(i); ListBox1.Items.Add( "r=" + j.ToString()); int tmp = array[j]; array[j] = array[i - 1]; array[i - 1] = tmp; } foreach ( int value in array) { ListBox1.Items.Add(value.ToString()); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | public static int Fibonacci( int n) { int a = 0; int b = 1; for ( int i = 0; i < n; i++) { int temp = a; a = b; b = temp + b; } return a; } private void button1_Click( object sender, EventArgs e) { listBox1.Items.Clear(); for ( int i = 0; i < 5; i++) { listBox1.Items.Add(i+"= " + Fibonacci(i)); } } |
1 2 3 4 5 6 7 8 9 10 11 | private void button1_Click( object sender, EventArgs e) { char [] buffer = new char [5]; for ( int i = 0; i < 5; i++) { buffer[i] = 'a' ; } string result = new string (buffer); listBox1.Items.Add(result); } |
1 2 3 4 5 6 7 8 9 10 11 12 | static class Perls { public static int _value = 5; } private void button1_Click( object sender, EventArgs e) { for ( int i = 0; i < 5; i++) { listBox1.Items.Add(++Perls._value); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | static class RandomLetter { static Random _random = new Random(); public static char GetLetter( int a) { char let = ( char )( 'a' + a); return let ; } } private void button1_Click( object sender, EventArgs e) { for ( int i = 0; i < 10; i++) { listBox1.Items.Add(RandomLetter.GetLetter(i)) ; } } |