Hương Trang
New member
What will be the output of the following C# code snippet?
A.
True
0
B. Run time error
C.
True
9
D. None of the mentioned
Code:
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
B. Run time error
C.
True
9
D. None of the mentioned