Interview Questions C#
Interview Questions C#
Interview Questions C#
ref keyword is used to pass an already initialized variable to a method as a reference type,
facilitating bi-directional data passing.
Whereas out keyword is used to pass a variable as an empty container that can store multiple
values to a method as a reference type. out keyword allows uni-directional data passing, as
the container passed using out keyword doesn’t need to be initialized beforehand.
Unboxing is the process of converting from a reference type to a value type. Here's a C#
example of unboxing.
// Unboxing
Object obj2 = 1;
int num2 = (int)obj;
Console.WriteLine(num2);
Console.WriteLine(obj);
3. What are the distinctions between Array and Array List in C#?
Arrays store values or elements of the same data type, whereas array lists store values of
various data types.
Arrays will use a fixed length, whereas array lists will not.