C Sharp Interview Questions
-
- What is C#?
- C#, also known as C Sharp is an object-oriented programming langauge that has certain characteristics such as type safe and managed language that is compiled by .Net framework to generate Microsoft Intermediate language.
- What are the main principles of Object-Oriented Programming that C# supports?
The four main OOP principles that C# supports are:
Encapsulation (binding data and methods together)
Inheritance (deriving new classes from existing ones)
Polymorphism (objects behaving differently based on data type)
Abstraction (hiding complex implementation details)
- What is the difference between Value Types and Reference Types in C#?
- Value types store the actual data value within its own memory allocation, like int, float, bool, etc. Reference types store a reference or pointer to the actual object's location in memory, such as strings, arrays, custom classes.
- Explain the purpose of the 'using' keyword in C#.
The 'using' keyword has two main uses:
To import .NET namespaces into C# code files
To implement IDisposable and ensure safe use and clean up of unmanaged resources
- What are Delegates in C#? Provide an example.
Delegates are type-safe, object-oriented function pointers in C#. They allow methods to be passed as parameters, stored in variables and invoked as needed.
Example: public delegate void PrintMessage(string msg);
- What is the difference between static and non-static classes in C#?
- A non-static class requires instantiation of an object to access its members. A static class cannot be instantiated and all its members must be static. It is designed to be used without creating instances.
- What is an Interface in C#? How does it differ from an Abstract class?
- An interface defines a contract of properties, methods and events that a class must implement. Unlike abstract classes, interfaces cannot have access modifiers and cannot contain implementation code. Classes can implement multiple interfaces.
- What are Generics in C#? How are they useful?
- Generics allow you to define type-safe, re-usable classes and methods that can work with any data type, rather than being specific to only one data type. This maximizes code reusability and type safety.
- What do you understand by the term 'Exception Handling' in C#?
- Exception handling is a mechanism to handle and recover from runtime errors in C# code. It uses try/catch/finally blocks to catch exceptions, take alternate actions and properly dispose resources in case of errors.
- Name some of the most commonly used data structures in C#.
Some of the key data structures are:
Arrays (fixed and resizable)
Lists
Dictionaries/HashTables
Stacks
Queues
LinkedLists
Trees
HashSets
Interested about C Sharp?
Get in touch with training experts Get Free QuotesLeave a commentLatest Jobs in US & Canada
.NET DEVELOPER CA PP
- 0 - 2 Years
- 16 hrs ago
- New York, NY
- US Citizen,Green Card
.NET Developer - TX - T
- 1 - 3 Years
- 4 days ago
- Austin, TX
- US Citizen,Green Card,H4
.NET Developer
- 1 - 8 Years
- 7 days ago
- Virginia Beach, VA
- US Citizen,Green Card,EAD / TN,H4,L2