Xem mẫu

Chapter 6. Arrays, Collection Types, and Iterators 1 Objectives “This chapter covers the various array and collection types available in C#. You can create two types of multidimensional arrays, as well as your own collection types while utilizing collection-utility classes. You’ll see how to define forward, reverse, and bidirectional iterators using the new iterator syntax introduced in C# 2.0, so that your collection types will work well with foreach statements.” Microsoft 2 Roadmap 6.1. Introduction to Arrays 6.2. Multidimentional 6.3. Multidimentional Rectangular Arrays Jagged Arrays 6.4. Collection Types 6.5. Iterators 6.6. Collection Initializers Microsoft 3 6.1. Introduction to Arrays Overview Implicitly Typed Arrays Type Convertibility and Covariance Arrays As Parameters (and Return Values) The System.Array Base Class Microsoft 4 Overview  An array is a set of data items, accessed using an numerical index  An array is a group of contiguous memory locations that all have the same name and type  Arrays are reference types, and the memory for the array is allocated on the managed heap.  Array Initialization Syntax:  Example: myInts[0] 100 Position number of the element within array myInts myInts[1] static void SimpleArrays() { Console.WriteLine("=> Simple Array Creation."); // Create and fill an array of 3 Integers int[] myInts = new int[3]; myInts[0] = 100; myInts[1] = 200; myInts[2] = 300; // Now print each value. foreach(int i in myInts) Console.WriteLine(i); Console.WriteLine(); myInts[2] 300 } Microsoft 5 ... - tailieumienphi.vn
nguon tai.lieu . vn