The c# programming language provides the rapid application development and It is the best language for writing Microsoft .NET applications. Its syntax is similar to C++ syntax. Here are top Basic and Advanced C# Interview Questions and Answers for Freshers and Experienced Dot Net developers.
C# is a modern, high level, general purpose object oriented programming language. This language is principal language of .Net framework. The design goal of the language was software robustness, durability & programmer productivity. It can be used to create a console application, GUI application, web application both on PC or embedded systems.
A class describes all attributes of objects as well as the method that implements the behavior of member object. Basically, it represents a blue print of object.
It is a template of an object. A class contains data & behavior of an entity.
Example: Aircraft.
Data: Model number of aircraft, Color of aircraft, category of aircraft etc.
Behavior/Method: Duration of flight, number of passengers etc.
An object is an instance of the class. It is a basic unit of the system. An object is an entity that has attributes, behavior & identity. Attributes & behavior of an object is defined by the class definition.
They both look very much same but they are not same. The class is definition while the object is the instance of the class created. The class is blue print while objects are actual
objects existing in the world.
Example: Car has attributes & method like speed, brake, type of car etc.
Following are the advantages of C#
Following are the IDE’s used for C# development
Struct & Class both are the user defined data type but have some major differences:
# | Struct | Class |
---|---|---|
1. | Structure are value type in C# & it inherits from System.ValueType. | Classes are reference type & it inherits from the System.Object Type. |
2. | Structure use stack to store value. | classes use heap to store value. |
3. | Structure can not be declared as protected . | Classes can not declare as protected. |
4. | We can not be able to use inheritance in Structure. | We can use inheritance in classes. |
5. | The struct can have the only constructor. | The class can have the constructor and destructor. |
6. | Structure objects can not destroy using GC. | Objects created from classes are terminated using GC. |
7. | The struct can instantiate without using the new keyword.. | The new keyword should be used to create the object for the class. |
8. | The struct can only inherit the interfaces. | The class can inherit the interfaces, abstract classes. |
Oops stands for object oriented programming system.
It is a problem-solving technique to think real world problems in terms of objects.
Following are different properties provided by oops
# | Abstraction | Encapsulation |
---|---|---|
1. | Abstraction solves the problem at design level. | Encapsulation solves the problem at the implementation level. |
2. | Abstraction is set to focus on the object instead of how it does it. | Encapsulation means hiding the internal details or mechanics of how an object does something. |
3. | Abstraction is used for hiding the unwanted data and giving only relevant data. | Encapsulation is hiding the code and data into a single unit to protect the data from the outer world. |
4. | Abstraction is implemented using interface & abstract class. | Encapsulation is implemented using private & protected access modifiers. |
5. | Abstraction is outer layout in terms of design. | Encapsulation is inner layout in terms of implementation. |
e.g. | Outer Look of an iPhone, like it has a display screen. | Inner Implementation detail of an iPhone, how Display Screen are connected with each other using circuits. |
The sealed class is used to stop the class from being inherited from other classes. If you define a class in C# as "Sealed" & "nonheritable" in VB.NET, then you can not inherit the class further.
Value types directly contain data and derived from System.ValueType.
Value types use the stack to store value.
Example: int, float, char, Bool, short
reference types stored the address of memory where data is stored
reference types use the heap to store value.
Example: Class, Interface, String, Object, Delegate, Array
# | Struct | Class |
---|---|---|
1. | They are stored on stack. | They are stored on heap. |
2. | Memory is allocated at compile time. | Memory is allocated at runtime. |
3. | The value type is popped on its own from the stack when they go out of scope. | Required garbage collector to free memory. |
4. | Value type contains actual value. | Reference type contains reference to a value. |
5. | Cannot contain null values. However, this can be achieved by nullable types. | Can contain null values. |
e.g. | int, float, char, Bool, short. | Class, Interface, String, Object, Delegate, Array. |
09 August 2017 2120 Written By: Rohit
Founded in 2016, Tech Study passionately delivers stylish and dynamic innovative information to programmer & technology lovers. http://www.techstudy.org/.
© 2018 Tech Study. All rights reserved | Developed by Tech Study| Privacy Policy | Sitemap