C Sharp Arrays Questions and Answers
Arrays are fundamental to programming in C#. This comprehensive set of C Sharp arrays programming questions with answers covers array declaration, initialization, multidimensional arrays, and looping concepts. Used widely in Infosys, TCS, and Wipro placement exams, these programming questions and answers help learners understand efficient data management in C#. Each question is accompanied by explanations and sample code, allowing candidates to master key array-handling techniques and perform well in technical interviews.
C Sharp Arrays
Showing 10 of
30 questions
21. Which loop is commonly used to iterate through all elements of an array?
- foreach
- for
- while
- do-while
22. How do you initialize an array with values at declaration?
- int[] arr = {1, 2, 3};
- int[] arr = [1, 2, 3];
- int[] arr = (1, 2, 3);
- int[] arr = new 1, 2, 3;
23. What is the difference between Array.Copy() and Array.Clone()?
- Clone creates new array, Copy needs destination
- Copy creates new array, Clone needs destination
- Both work exactly the same
- Clone is faster than Copy
24. Which property gives the rank (number of dimensions) of an array?
- Rank
- Dimensions
- Length
- Size
25. How do you resize an array in C#?
- Array.Resize()
- array.Resize()
- Resize(array)
- array.Size = newSize
26. What is the output of Array.BinarySearch() if element is not found?
- Negative number
- 0
- null
- -1
27. Which collection is similar to array but can dynamically grow?
- List<T>
- ArrayList
- Dictionary<T>
- HashSet<T>
28. How do you clear all elements of an array?
- Array.Clear()
- array.Clear()
- Clear(array)
- array.RemoveAll()
29. What is the main advantage of using arrays over lists?
- Better performance
- Dynamic resizing
- Built-in sorting
- Automatic indexing
30. Which method converts an array to string representation?
- String.Join()
- array.ToString()
- Convert.ToString(array)
- array.String()