Chương 10 Quick tham khảo để làm này Ghi rõ tên của các loại nguyên tố, tiếp theo là dấu ngoặc vuông, theo sau là tên của biến, theo sau là một dấu chấm phẩy. Khai báo một mảng Ví dụ: biến bool [] cờ; | Chapter 10 Quick Reference To Do this Write the name of the element type followed by square brackets A followed by the name of the variable followed by a semicolon. Declare an array For example variable bool flags Create an instance of an array Write the keyword new followed by the name of the element type followed by the size of the array between square brackets. For example Initialize the elements of an array instance to specific values bool flags new bool 10 Write the specific values in a comma-separated list between curly brackets. For example Find the number of elements in an array bool flags true false true false Use the Length property. For example Access a single array element int noOfElements Write the name of the array variable followed by the integer index of the element between square brackets. Remember array indexing starts at zero not one. For example bool initialElement flags 0 Use a for statement or a foreach statement. For example Iterate through the elements of an array or collection bool flags true false true false for int i 0 i i flags i Find the number of elements in a collection foreach bool flag in flags flag Use the Count property. For example int noOfElements