C# Interview Questions and Answers
C#, sometimes also called as C sharp, is a component-oriented, general-purpose computer programming language that encompasses strong typing, declarative, imperative, and object-oriented disciplines. This information has been asked quite a few times recently in C# interview questions. It is a multi-paradigm language that was initially designed for Common Language Infrastructure (CLI).
C# allows the developers to build reusable components for a huge variety of applications. C# is an evolution or extension of C and C++ languages. However, it has taken much of its features from other programming languages as well, including Delphi and Java. When you analyze the basic syntax of C# and Java and C++, it will look very similar, which is intentional and not a coincidence.
Most Frequently Asked C# Interview Questions
It is a collection of keys or value pairs that contains values based on keys.
Converting a specific value type to a particular reference type is known as Boxing.
Whereas, explicit conversion of same reference types, that were created during boxing, back to the same value type is known as Unboxing.
StreamReader and StreamWriter are two different classes in namespace System.IO. Both of these classes are used when the user wants to read or write charact90 and Reader-based data, respectively.
Members of StreamReader inlcude, Close(), Read(), Readline().
Members of StreamWriter include, Close(), Write(), Writeline().
This is an essential topic in C# interview questions for experienced professionals. Some of the basic string operations in C# are Concatenate, Modify, Compare and Search.
A Delegate in C# is a variable, which holds a reference to a specific method. This also makes a delegate a function pointer of a reference type. All the Delegates are derived from the System. Delegate namespace.
Delegates are of three types -
- Single Delegate
- Multicast Delegate
- Generic Delegate
Synchronous is one of the ways to create a thread-safe code in C# where only one thread is able to access resources at any time.
Asynchronous call waits for a method to get completed before continuing with program flow. In an Asynchronous operation, the method call immediately returns so that the program can perform operations while the called method finished its task.
S.no | System.Array.Clone() | System.Array.CopyTo() |
---|---|---|
1. | Used for creating a new array containing elements of the original array | Elements of existing array get copied into another existing array. |
2. | Does not require a destination array to exist | Destination array must exist |
"is" operator
- Used to check compatibility of the object with a given type
- Returns result as Boolean.
"as" operator
- Used for the casting of the object to type or class
Advantages
- Easy to understand
- Object and component-oriented
- Faster and safer
C# has grown very rapidly and is used widely. It is mostly because of its versatile syntax and cross-platform support. Developers who are trained in Java, C+ or C++ will be easily and quickly able to work in C#. We have updated our C# interview questions for freshers. The lambda expressions, nullable value types, direct memory access, delegates, and enumerations are powerful features that simplify the language C++; and on top of it, these add-ons are not available in other languages, such as Java.
Latest Version
Read more about recent versions if you are preparing for C# interview questions. The latest version, C# 7.3, was released in 2018.
Development History
C# was developed by Microsoft around the year 2000 within the .NET initiative. Later, this language got approved by Ecma (ECMA-334) as a standard. Designed by Anders Hejlsberg, the current development of C# is being taken care of by Mads Torgersen.