1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace ArrayExamples { public partial class fArrayExamples : Form { public fArrayExamples() { InitializeComponent(); } private void createArray_way1_Click(object sender, EventArgs e) { // Create and initialization of array of 3 elements way 1 int[] someIntArray = new int[3]; someIntArray[0] = 1; someIntArray[1] = 2; someIntArray[2] = 3; textBox.Text += "Create and initialization of array of 3 elements way 1" + Environment.NewLine + ""; textBox.Text += Environment.NewLine + " someIntArray[1]=" + someIntArray[0].ToString() + Environment.NewLine + " someIntArray[2]=" + someIntArray[1].ToString() + Environment.NewLine + " someIntArray[3]=" + someIntArray[2].ToString() + Environment.NewLine; } private void createArray_way2_Click(object sender, EventArgs e) { textBox.Text += Environment.NewLine; // Create and initialization of array of 3 elements way 2 textBox.Text += "Create and initialization of array of 3 elements way 2" + Environment.NewLine+""; int[] someIntArray2 = { 1, 2, 3 }; textBox.Text += Environment.NewLine + " someIntArray[1]=" + someIntArray2[0].ToString() + Environment.NewLine + " someIntArray[2]=" + someIntArray2[1].ToString() + Environment.NewLine + " someIntArray[3]=" + someIntArray2[2].ToString() + Environment.NewLine; } private void create3DimensionalArray_Click(object sender, EventArgs e) { textBox.Text += Environment.NewLine; int[,,] some3DArray = new int[1, 1, 1]; textBox.Text += "Create and initialization of 3 dimensional array" + Environment.NewLine + ""; textBox.Text += Environment.NewLine + " some3DArray[0,0,0]=" + some3DArray[0, 0, 0].ToString() + Environment.NewLine; } } } |