Difficulty: Easy
Correct Answer: 1) It is a rectangular array of 2 rows and 3 columns. 2) intMyArr.GetUpperBound(1) yields 2.
Explanation:
Introduction / Context:Rectangular arrays in C# are true multi-dimensional arrays (as opposed to jagged arrays of arrays). Knowing how to interpret bounds and length avoids off-by-one errors.
Given Data / Assumptions:
Concept / Approach:A 2x3 rectangular array has row indices 0..1 and column indices 0..2. GetUpperBound(dimension) returns the highest valid index on that dimension. Length returns total elements (rows * columns = 6).
Step-by-Step Solution:
1) Rectangular 2 rows × 3 columns — True.2)GetUpperBound(1) → last column index = 2 — True.3) Length = 6, not 24 — False.4) Not a 1-D array — False.5) GetUpperBound(0) = 1 (rows 0..1), not 2 — False.Verification / Alternative check:Simple console prints confirm that intMyArr.Length == 6, GetUpperBound(0) == 1, GetUpperBound(1) == 2.
Why Other Options Are Wrong:
Common Pitfalls:Confusing element count (Length) with byte size or misremembering 1-based versus 0-based indices.
Final Answer:1, 2
Discussion & Comments