C Sharp Interview Questions for Testers
Q1. What is a jagged array in c sharp?
Jagged arrays are also known as arrays of arrays. They are called so because these are arrays whose elements are arrays possibly of different sizes. While working with a multidimensional array, a jagged array can be used to store rows of data of varying lengths to improve their performance. It gives ease of memory management that helps in the smooth execution of programs.
Q2. Mention the various types of comments used in c#
Single line comment: It is used to comment on a single line. These comments can be written in a separate line or along with the codes in the same line. For better use, it is beneficial to use it in a separate line.Syntax- // Single Line Comments
Multiline comment: It is used to comment on more than one line. Generally, it is used to comment out an entire block of code statements.
/* Multiline Comment */
- XML comment: this is a special type of comment that is mostly used in c# code documentation by adding XML elements in the source code.
/// <summary> /// This class does something of program Summary. /// </summary>
Q3. List Down some of the names of different IDE's provided by Microsoft for c# development.
Below listed are a few IDE’s for C# development:
- Visual Studio Express (VCE)
- Visual Studio (VS)
- Visual Web Developer
Q4. Explain the stream reader/stream writer class.
When you want to read or write character-based data, a stream reader or stream writer comes into the picture. These are found in the system. IO namespace.
members of StreamReader are: close(), Read(), Readline().
members of Streamwriter are: close(), write(), writeline().
Q5. What is an escape sequence? List a few of its strings.
The combination of character sequence having a backslash () followed by a letter or combining digits gives rise to escape sequence. It doesn’t represent itself when used inside a character or a string but gives a character that has special meaning to the compiler.
Some escape sequences are as follow:
- \n – newline character
- \b – backspace
- \\– backslash
- \ '– Single quote
- \" – Double quote
Q6. Suppose you are required to create and compile an application in c#, name the files generated in the debug folder.
When creating and compiling a program in C#, the Below files will appear in your debug folder.
– exe – This is the ‘normal’ executable
– vshost.exe – a special version of the executable to aid debugging
PDB – it is the Program database with debugged symbols
– vshost.exe.manifest – a configuration file containing mostly dependencies on libraries.
Q7. What is the async method in c#? State its importance.
An async method is a method that runs synchronously until it reaches its first await expression, at which point the method is suspended until the awaited task is completed. The compiler in the background generates a state machine.
An async method shows the following properties:
- It must have the keyword" async" in its method header, which must be placed before the return type.
- This modifier's work is nothing much. one or more await expressions are contained in this method.
- These await expressions represent tasks that can be done asynchronously.
- It should have one of the following three return types.
- void: If the calling method wants the async method to execute but doesn't need any further interaction with it
- Task: If the calling method doesn't need a return value from the async method but needs to be able to check on the async method's state
- Task: If the calling method is to receive a value of type T back from the call, the return type of the async method must be the task
- This method can contain any number of formal parameters of any type, but it cannot be 'out' or 'ref' parameters.
- The suffix "Async" must be added at the end of the name of an async method.
- Other methods such as lambda expressions and anonymous methods can also act as async objects.
Other useful articles:
- TOP-10 Basic C# Interview Questions and Answers
- TOP-10 C# Questions for Advanced Programmers
- 10 Important C# Interview Questions and Answers
- Most Asked C# Interview Q & A
- C# Interview for Beginners
- TOP-10 Advanced C# Interview Questions and Answers
- Introduction to Functions in C#
- C# Jagged Arrays
- C Sharp Interview Questions for 5 Years Experience
- C Sharp Interview Questions for Testers
- C Sharp Questions for 10 Years Experience
- Iteration Statements in C#
- Exception Handling in C#