-
How do you declare a variable in C#?
a) var x = 10;
b) variable x = 10;
c) int x = 10;
-
What is the output of the following C# code snippet?
int x = 10;
Console.WriteLine(x.GetType());
x = 20;
Console.WriteLine(x.GetType());
a) System.Int32 and System.Int32
b) int and int
c) int32 and int32
-
Which C# loop is used to iterate over a range of values?
a) for
b) while
c) foreach
-
In C#, what is used to handle error conditions and exceptions?
a) try
b) catch
c) finally
-
What keyword is used in C# to throw an exception manually?
a) throw
b) try
c) exception
-
Which C# namespace is used for input and output operations?
a) System.IO
b) System.Console
c) System.Text
-
In which programming language is C# primarily implemented?
a) C++
b) Java
c) C#
-
What will be the output of the following C# code?
int[] a = {1, 2, 3};
int[] b = a;
b[0] = 5;
Console.WriteLine(string.Join(" ", a));
a) 1 2 3
b) 5 2 3
c) 1 5 3