Interview questions for C# language

Q10: What are Custom Control and User Control?

Ans: Custom controls are compiled code (DLLs) controls; they may be more easily used and added to the toolbox. Developers may drag and drop web-based controls. Attributes may, at the time of design. Multiple applications can be added with individual controls (If Shared Dlls). So, if it's personal, we may copy the reference and then utilize it in dll to the bin directory of the web application.

User Controls contain files that are quite similar to ASP and can be easily created. User controls cannot be put and dragged into the toolbox — they're dumped. They have both their design and their code. The user control file extension is ascx.

Q11: What are the differences between IEnumerable and IQueryable?

Ans: Before we go into the differences, let's learn what the IEnumerable and IQueryable are.


For all non-generic collections in system it is the parental interface. Name Space Collections, e.g. ArrayList, HastTable, etc. This interface is generically IEnumerable, the interface parent of all general classes in the system of collections. General namespace collections, including List<> and more. Collections.


According to MSDN, the IQueryable interface is designed for query providers implementation. Providers that implement IQueryable should only be implemented. If the IQueryable does not implement the provider, the default query operators on the provider's data source cannot be utilised.

The interface IQueryable inherits IEnumerable so that the results of a query may be listed when it represents a query. The listing leads to the execution of the expression tree using an IQueryable object. A query provider is specifically defined to "run an expression tree."

This may include, for instance, translating the expression tree for the underlying source into a suitable query language. When the Execute method is invoked, queries that do not return enumerated outcomes are performed.

Q12: What are Singleton Design Patterns and how to implement them in C#?

Ans: Makes ensuring that a class has only one instance and offers a global access point. A Singleton is a class that only permits a single instance and typically offers easy access.

Individual tones often do not enable to specify parameters when the instance is set, as the second instance request may be an issue with a different parameter! (If all applications with the same parameter have to access the same instance, the factory design would be better.)
The singleton pattern in C# may be implemented in several ways. The following are the common features of a single pattern.

A single builder, private and without parameters. The class has been sealed.

A static variable with a reference, if applicable, to the single instance generated. A public static way to acquire the reference to the single instance, if required, that creates one.

Q13: What is a Virtual Method in C#?

Ans: A virtual method is a way of redefining it in derived classes. A virtual method has both a basic class implementation and a class implementation. It is utilized when the fundamental functionality of a method is equal; however, in the derived class, it occasionally requires extra functionality. The basic class that may be overridden in the derivative class has a virtual method. We use the virtual keyword to construct a virtual procedure in the base class and override the method using an override keyword in the derived class.

If a method in a base class is designated a virtual approach, the method can be specified in a base class, and the derived class can optionally override it. More than one form for a method is provided by the overriding method. It is, therefore, a polymorphic example too.

When a method in a base class is declared as a virtual method, and in a derived class, the same method definition is present, the derived class doesn't need to override it. But if there is another definition of a virtual method in the basic class and the derived class, the derived class must be overridden.

If a virtual method is invoked, an overriding member will check the run-time type of the object. The overriding member is called in the most derived class, which may be the original member unless a derived class overrides a member.

Virtual Method

By default, methods are non-virtual. We can't override a non-virtual method. We can't use the virtual modifier with static, abstract, private, or override modifiers.

Q14: What is Serialization in C#?

Ans: Serialization in C# is the process by which an object is converted to a byte stream to save the object, a database, or a file. Its major aim is to store the condition of an item so that it may be recreated as necessary. Deserialization is the opposite procedure.

There are three types of serialization,

Binary serialization (Save your object data into binary format).
Soap Serialization (Save your object data into binary format; mainly used in network-related communication).

XmlSerialization (Save your object data into an XML file).

Q15: What is MultithreadingMultithreading with .NET?

Ans: A software can execute many threads at the same time. MultithreadingMultithreading this article covers the functioning of multithreading in.NET. This page covers the whole spectrum of threading regions from creating threads and circumstances of race, impediments, screens, mutexes, and semaphores, etc.

The proper use is not a sequential thread; rather, a single software uses numerous threads. MultithreadingMultithreading is referred to as several threads that operate simultaneously and accomplish separate tasks. A thread is considered a lightweight process because it is part of a program and utilizes the resources assigned to it.

There is just one thread in a single-threaded process while more than one thread in a multithreaded process.