gs gs108 Delegates, Generics and LINQ - Introduction of Array Class - Quiz No.1
gs gs108 CSharp Quiz
This quiz belongs to book/course code gs gs108 CSharp of gs organization. We have 110 quizzes available related to the book/course CSharp. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Delegates, Generics and LINQ. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
public bool IsReadOnly { get; }
public static int BinarySearch<T>(T[] array, int index, int length, T value)
static void Main(string[] args) { int[] nums = { 5, 4, 6, 3, 14, 9, 8, 17, 1, 24, -1, 0 }; Array.Sort(nums); int idx = Array.BinarySearch(nums, 14); if (idx == 9) { Console.WriteLine(Convert.ToBoolean(1)); } else { Console.WriteLine(Convert.ToBoolean(0)); } Console.WriteLine("Index of 14 is " + idx); Console.ReadLine(); }
True 0
True 9
static void Main(string[] args) { string[] strings = {"beta", "alpha", "gamma"}; Console.WriteLine("Array elements: "); DisplayArray(strings); Array.Reverse(strings); Console.WriteLine("Array elements now: "); DisplayArray(strings); Console.ReadLine(); } public static void DisplayArray(Array array) { foreach (object o in array) { Console.Write("{0} ", o); } Console.WriteLine(); }
Array elements: beta alpha gamma Array elements now: ammag ahpla ateb
Array elements: beta alpha gamma Array elements now: gamma beta alpha
Array elements: beta alpha gamma Array elements now: gamma alpha beta
int[] a; a = new int[3] a[0] = 25 a[1] = 30 a[2] = 40 a[3] = 5
int[] a a = new int[4]{25, 30, 40, 5}
int[] a a = new int[4] a[0] = 25 a[1] = 30 a[2] = 40 a[3] = 5