chapter Five
Property
Nothing is worth mentioning ......................
2. Arrangement of multi-dimensional array and arrays
The second name listened to it, I don't know what is good, the book is jagged arrays.
The first is a multi-dimensional array, there is nothing special, that is, when defined, there is different Double Double [,,] NumBers; this defines a three-dimensional array, knowing that the number of dimensions of array is very easy, and several commas plus 1 You can look at how to use the multi-dimensional array
Using system;
Class multidimarrayapp {protected int currentmonth; protected double [,] sales;
MultidimarrayApp ()
{CurrentMonth = 10;
Sales = new double [2, currentmonth]; for (int i = 0; i Protected Void Printsales () {Console.writeline ("Printing A Multi-Dimensional" "Array Of NumBers ... / N"); for (int i = 0; i The place you need to pay attention is that the getLength function, if you use the length attribute to get a long distance of the array, for a single-dimensional array, the same as getlength but for multi-dimensional arrays, Length is the entire length, that is, each The sum of dimensions, corresponding to the above example is 20, but the length of the nth dimension is obtained by GetLength (n). PS: Get the dimension of the array using the RANK attribute The array of arrays, feelings and C are similar, used to organize other arrays, the Dongdong this is the definition int [] [] jaggedArray; and the multi-dimensional number of different groups will come to a small example. Class Control {Virtual Public Void Sayhi () {Console.writeLine ("Base Control Class");}} class Button: Control {override public void SayHi () {Console.WriteLine ( "button control");}} class Combo: Control {override public void SayHi () {Console.WriteLine ( "combobox control");}} class JaggedArrayApp {public static void Main () {// Define a two-dimensional array as a "parent" array // The first dimension represents how many arrays // this parent array will contain Control [] [] controls;.. controls = New Control [2] []; // the first Dimension Will Contain Three Controls ... Controls [0] = New Control [3]; for (int i = 0; i // the second Dimension Will Contain Two Controls ... Controls [1] = new control [2]; for (int i = 0; i // now i can simply iterate through a nested for loop // and using polymorphism access all my control '// members! For (int i = 0; i The result of the output is Button Controlbutton ControlButton ControlComboBox ControlComboBox Control 3. Treat your class like the IdExer icon The new feature of C #, look at the example and know Using system; using system.collections; Class mylistbox {Protected ArrayList Data = New ArrayList (); Public Object this [int idx] {get {if (idx> -1 && idx This keyword is used here to represent Indexer. At this point, MYLISTBOX is like an array. How is it implemented inside? The compiler will add a attribute to myListbox called item, and it is called this property.