Reference Page: C-Language|C++|C#|VB.Net|Asp.Net

C# Links : Learn     Interview Questions     Software IDE C# jobs : Indeed.com     ZipRecruiter.com     Monster.com

C# Interview Questions - Page 1

Next Page >
Question: What are the different access modifiers in C#?
Answer: C# supports five access modifiers:
• public
• private
• protected
• internal
• protected internal

Question: What is the difference between value types and reference types in C#?
Answer: Value types store their actual data value in memory, whereas reference types store a reference to the location of the data.
Value types include primitive types like int, float, and structs, while reference types include classes, interfaces, arrays, and delegates.

Question: Can you explain the difference between 'ref' and 'out' keywords in C#?
Answer: Both 'ref' and 'out' are used for passing arguments to methods by reference. However, 'ref' requires that the variable be initialized before being passed to the method, whereas 'out' does not.

Question: What is the purpose of the 'using' statement in C#?
Answer: The 'using' statement is used to ensure that IDisposable objects are properly disposed of after use. It automatically calls the Dispose() method on objects when they go out of scope, ensuring efficient resource management.

Question: What is the difference between 'String' and 'StringBuilder' in C#?
Answer: The 'String' is an immutable type, meaning its value cannot be changed after it is created.
The 'StringBuilder', on the other hand, is mutable and allows for efficient manipulation of strings, particularly when concatenating multiple strings in a loop.

Question: What are delegates in C#?
Answer: Delegates are type-safe function pointers that allow methods to be passed as parameters to other methods or assigned to variables. They are commonly used for implementing callbacks, event handling, and asynchronous programming.

Question: What is inheritance and how is it implemented in C#?
Answer: Inheritance is a mechanism in object-oriented programming where a class (derived class) can inherit properties and behaviors from another class (base class).
In C#, inheritance is implemented using the colon (:) syntax, specifying the base class after the derived class name.

Question: Can you explain the difference between '== 'and '.Equals()' in C# for comparing objects?
Answer: The '==' is used to compare object references for equality, while '.Equals()' is a method that can be overridden by classes to define custom equality comparisons.

By default, '.Equals()' performs a reference equality check similar to '==', but it can be overridden to perform value equality checks.


Next Page >