C Sharp Arrays Questions and Answers

Take Exam

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
Show Answer Report

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;
Show Answer Report

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
Show Answer Report

24. Which property gives the rank (number of dimensions) of an array?

  • Rank
  • Dimensions
  • Length
  • Size
Show Answer Report

25. How do you resize an array in C#?

  • Array.Resize()
  • array.Resize()
  • Resize(array)
  • array.Size = newSize
Show Answer Report

26. What is the output of Array.BinarySearch() if element is not found?

  • Negative number
  • 0
  • null
  • -1
Show Answer Report

27. Which collection is similar to array but can dynamically grow?

  • List<T>
  • ArrayList
  • Dictionary<T>
  • HashSet<T>
Show Answer Report

28. How do you clear all elements of an array?

  • Array.Clear()
  • array.Clear()
  • Clear(array)
  • array.RemoveAll()
Show Answer Report

29. What is the main advantage of using arrays over lists?

  • Better performance
  • Dynamic resizing
  • Built-in sorting
  • Automatic indexing
Show Answer Report

30. Which method converts an array to string representation?

  • String.Join()
  • array.ToString()
  • Convert.ToString(array)
  • array.String()
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test