C# Interview Questions And Answers
In this article, I am going to discuss the most frequently asked Basic C# Interview Questions and Answers. As part of this article, we are going to discuss the following C# Interview Questions with Answers.
- What is COM?
- What are the disadvantages of COM?
- What .NET Represents?
- What is a Framework and what does the .NET Framework provide?
- Explain about CLR and its Execution Process.
- What is exactly .NET?
- What are the language and its need?
- What are Technology and its need?
- What is Visual Studio?
- Explain about BCL.
- What is the Just-In-Time (JIT) compilation?
- What is Metadata?
- What is an assembly?
- What are the differences between managed code and unmanaged code?
- What is C#?
- What is the difference between an EXE and a DLL?
- What’s the difference between IEnumerable<T> and List<T>?
- Why is class an abstract data type?
- What are the new features introduced in c# 7?
What is COM?
- COM stands for Component Object Model.
- COM is one of Microsoft Technology. Using this technology we can develop windows applications as well as web applications.
In earlier COM, VB is the programming language that is used to implement windows application and ASP is used to implement web applications.
What are the disadvantages of COM?
The major two disadvantages of COM is
- Incomplete object-oriented programming means it will not support all the features of OOPs.
- Platform dependent means COM applications can run on only Windows OS.
What .NET Represents?
- NET stands for Network Enabled Technology.
- In .NET dot (.) refers to object-oriented and NET refers to the internet.
So the complete .NET means through object-oriented we can implement internet applications.
What is a Framework?
A framework is a software. Or we can say that a framework is a collection of many small technologies integrated together to develop applications that can be executed anywhere.
What does the .NET Framework provide?
.NET Framework provides two things such as
- BCL (Base Class Libraries)
- CLR (Common Language Runtime)
Explain about BCL.
- Base Class Libraries are designed by Microsoft.
- Without BCL we can’t write any code in .NET so BCL also was known as Building block of Programs of .NET.
- These are installed into the machine when we installed the .NET framework into the machine.
The physical location of BCL is C:\Windows\assembly
BCL contains predefined classes and these classes are used for the purpose of application development.
Explain about CLR and its Execution process.
CLR is the core component under the .NET framework which is responsible for converting MSIL code into native code and then execution.
In .NET, the code is compiled twice.
- In 1st compilation source code is compiled by respective language compiler and intermediate code is generated known as MSIL (Microsoft Intermediate Language) or IL (Intermediate language code) Or Managed code.
- In the 2nd compilation, MSIL is converted into Native code using CLR.
Always 1st compilation is slow and 2nd compilation is first.
What is JIT?
- JIT stands for Just-in-time.
- JIT is the component of CLR which is responsible for converting MSIL code into Native code.
- This Native code is directly understandable by the operating system.
Explain different types of .NET Framework.
The .net framework is available in three different types
- .NET Framework: This is the general version required to run .NET applications on Windows OS only.
- .NET mono Framework: This is required if we want to run .NET applications on other OS like Unix, Linux, MAC OS, etc.
- .NET Compact Framework: This is required to run .NET applications on other devices like mobile phones and smartphones.
NOTE: MSIL is only CPU dependent and will run only on Windows OS only using .NET Framework because .NET Framework is designed for Windows OS only.
There is another company known as “NOVEL” designed separate framework known as “MONO Framework”. Using this framework we can run MSIL on different OS Like Linux, UNIX, Mac, BSD, OSX, etc.
.NET is platform-dependent using the .NET framework but independent using the MONO framework.
What is not .NET?
- .NET is not an Operating system.
- It is not an application or package.
- .NET is not a database.
- It is not an ERP application.
- .NET is not a Testing Tool.
- It is not a programming language.
What is exactly .NET?
.NET is a framework tool that supports many programming languages and many technologies. It supports 60+ programming languages. In 60+ programming languages, 9 are designed by Microsoft and remaining are designed by Non-Microsoft.
Microsoft designed programming languages are as follows
- Iron phyton
- Iron Ruby
Technologies supported by the .NET framework are as follows
- ASP.NET (Active Server Pages.NET)
- ADO.NET (Active Data Object.NET)
- WCF (Windows Communication Foundation)
- WPF (Windows Presentation Foundation)
- WWF (Windows Workflow Foundation)
- LINQ (Language Integrated Query)
- ASP.NET MVC (Model View Controller)
- ASP.NET WEB API
What are the language and its need?
- A language acts as the mediator between the programmer and the system.
- It offers some rules and regulations for writing the program.
- The language also offers some libraries which are required for writing the program.
- The collection of programs is called software.
What are Technology and it’s needs?
Technology is designed for a particular purpose. For example development of web-related applications in .NET using a technology ASP.NET. But the technology does not offer any specific rules for writing the programs. That’s why technology can’t be implemented individually.
VB.NET, C#.NET both are programming languages. Using these two languages we can implement windows/desktop applications individually. Every language is having its own compiler
VB.NET and C#.NET both are programming languages. Using these two programming languages we can develop windows applications.
- ASP.NET is a part of a Framework.
- The ASP.NET is a technology which provides a set of predefined classes. Using these classes we can implement web applications.
- ASP.NET is needed language support.
- ADO stands for ActiveX Data Objects.
- The ADO.NET is a .NET database technology.
- ADO.NET provides a set of predefined classes. Using these predefined classes we can perform the operations with the database server.
- WCF stands for Windows Communication Foundation.
- The WCF is a distributed technology. Using this technology we can implement SOA (Service Oriented Architecture) programming.
- SOA programming provides communication between heterogeneous applications.
- Applications that are developed using different technologies or different programming languages are known as heterogeneous applications.
- The WPF stands for windows presentation foundation.
- WPF is a .NET technology using this technology we can create 2D, 3D, graphics, animations for windows application.
- Using this technology we can also create our own audio/video players and also implement gaming applications.
- LINQ stands for Language Integrated Query.
- It is query-writing Technology.
- LINQ offers to write queries in the programming code itself.
- This concept is introduced in .NET framework 3.5
- LINQ queries applying in database data and non-database data also.
What is Visual Studio?
Visual Studio is a Microsoft IDE tool which is needed to develop applications with the .NET framework. The IDE integrates 3 features
What is .net?
- .NET is a programming framework created by Microsoft that developers can use to create applications more easily. The framework provides libraries commonly used by developers. The .NET Base Class Libraries (BCL) servers that purpose.
- The .NET provides language interoperability across several programming languages. Programs are written for .NET Framework execute in a software environment called Common Language Runtime (CLR).
- CLR is the foundation of the .NET framework which provides services like safety, memory management, garbage collection, and exception handling.
- CLR manages the execution of code. The code that is managed by CLR is called managed code. Unmanaged code does not get managed by CLR. CLR’s interoperability helps to interact between managed and unmanaged code.
- Common Language Specification (CLS) and Common Type System (CTS) as part of CLR. CTS is responsible for interpreting data types into a common format. CLS provides the ability of code to interact with code that is written with a different programming language.
What is the Just-In-Time (JIT) compilation?
The MSIL is the language that all of the .NET languages compile down to. After they are in this intermediate language, a process called Just-In-Time compilation occurs when resources are used from our application at runtime.
What is metadata?
Metadata describes every type and member defined in our code in a Multilanguage form. Metadata stores the following information.
- Description of assembly.
- Identity (name, version, culture, public key).
- The types that are exported
- Other assemblies that this assembly depends on.
- Security permissions needed to run.
What is an assembly?
Assemblies are the building block of .NET framework applications; they form the fundamental unit of deployment, version control, reuse, and activation scoping and security permissions.
What are the differences between managed code and unmanaged code?
- Machine instructions are in MSIL format and located in assemblies will be executed by the CLR will have the following advantages
- Memory management to prevent memory leaks in program code.
- Thread execution
- Code safety verification
Unmanaged code/ methods:
- The Unmanaged codes are the instructions which are targeted for specific platforms. Unmanaged code will exist in any of the formats.
- COM/COM+ components
- Win 32 Dlls/system DLLs
- As these codes are in native formats of OS, these instructions will be executed faster compared with JIT compilation and execution of managed code.
What is C#?
C# is an object-oriented type safe and managed language that is compiled by.Net framework to generate Microsoft Intermediate Language.
What is the difference between an EXE and a DLL?
EXE is an executable file and can run by itself as an application whereas DLL is usually consumed by an EXE or by another DLL and we cannot run or execute DLL directly.
For example in .NET compiling a Console Application or a Windows Application generates EXE, whereas compiling a Class Library Project or an ASP.NET web application generates DLL. In the .NET framework, both EXE and DLL are called assemblies.
A DLL can be reused in the application whereas an exe file can never be reused in an application.
EXE stands for executable, and DLL stands for Dynamic Link Library
What’s the difference between IEnumerable<T> and List<T>?
- IEnumerable is an interface, whereas List is one specific implementation of IEnumerable. A list is a class.
- FOR-EACH loop is the only possible way to iterate through a collection of IEnumerable whereas List can be iterated using several ways. The list can also be indexed by an int index, the element can be added to and removed from and have items inserted at a particular index.
- IEnumerable doesn’t allow random access, whereas List does allow random access using the integral index.
- In general from a performance standpoint, iterating through IEnumerable is much faster than iterating thru a List.
Why is class an abstract data type?
A Class is an Abstract Data Type because it specifies what data members and member functions (methods) contain in it (class), but won’t provide information on how those are implemented. That makes Class Abstract and Class is User Defined DataType. So, it’s an Abstract Data Type
What are the new features introduced in c# 7?
This is a very commonly asked c# interview question. This question is basically asked to check if you are passionate about catching up with the latest technological advancements. The list below shows the new features that are introduced in c# 7.
Let’s have a look at the new features that are introduced as part of C# 7
- Out variables
- Pattern matching
- Digit Separators
- Deconstruction (Splitting Tuples)
- Local functions
- Literal improvements
- Ref returns and locals
- Generalized async return types
- More expression-bodied members
- Throw expressions
- Async main
- Default literal expressions
- Inferred tuple element names
In the next article, I am going to discuss Interface and Inheritance related interview questions and answers in C#. Here, in this article, I try to explain most frequently asked Basic C# Interview Questions and Answers. I hope this article will help you with your needs.