This program is show int array in C#.net. you can use four methods for this each method is show in the button click event.
C#.net Code For Int Array
Download project
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Array_2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void arrwithnewkeywordbutton_Click(object sender, EventArgs e) { listBox1.Items.Clear(); int[] MIT31043; MIT31043 = new int[60]; for (int counter = 0; counter <MIT31043.Length; counter++) { MIT31043[counter] =counter+ 1; listBox1.Items.Add(MIT31043[counter].ToString()); } } private void arrinitializerbutton_Click(object sender, EventArgs e) { listBox1.Items.Clear(); int[] number = {11,22,33,44,55 }; for (int counter = 0; counter < number.Length; counter++) { listBox1.Items.Add(number[counter]); } } private void calculationwitharrbutton_Click(object sender, EventArgs e) { listBox1.Items.Clear(); int counter; int[] mit = new int[5]; for (counter = 0; counter < mit.Length; counter++) { mit[counter] = counter * 3; listBox1.Items.Add(mit[counter]); } } private void usingforeachbutton_Click(object sender, EventArgs e) { listBox1.Items.Clear(); int sum = 0; int[] mit = {12,23,34,45,56,67 }; foreach (int counter in mit) { sum += counter; listBox1.Items.Add(counter); } listBox1.Items.Add("==============="); listBox1.Items.Add(sum); } } }
0 comments: