C Sharp interview Questions Part 4

C Sharp Interview Questions part 1

C Sharp – Interview Questions
What is C#?
is a modern, general-purpose, object-oriented programming language developed by Microsoft. C# is designed for Common Language Infrastructure (CLI), which consists of the executable code and runtime environment that allows use of various high-level languages on different computer platforms and architectures.


What is Jagged Array in C#?

A Jagged array is an array of arrays.
You can initialize a jagged array as −
int[][] scores = new int[2][]{new int[]{92,93,94},new int[]{85,66,87,88}};
Where, scores is an array of two arrays of integers – scores[0] is an array of 3 integers and scores[1] is an array of 4 integers.


In how many ways you can pass parameters to a method?

There are three ways that parameters can be passed to a method −
Value parameters − This method copies the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function have no effect on the argument.
Reference parameters − This method copies the reference to the memory location of an argument into the formal parameter. This means that changes made to the parameter affect the argument.
Output parameters − This method helps in returning more than a one value.


Can you return multiple values from a function in C#?

Yes! Using output parameters. A return statement can be used for returning only one value from a function. However, using output parameters, you can return two values from a function.


What is the difference between ref and out parameters?

Output parameters are similar to reference parameters, except that they transfer data out of the method rather than into it. Reference parameter copies the reference to the memory location of an argument into the formal parameter. This means that changes made to the parameter affect the argument.