Category: C# Advanced

This section contains awesome C# advanced interview questions and answers with example and descriptions for experienced, asked in technical interviews |Only Real.

What is Use of Private Constructor in C# ? Scenarios Example

Answer to interview questions, what is use of private constructor in c# language includes definition of it and when or why to use private constructors in c sharp  application with c# program example. Private Constructor in C#? Private constructor is constructor that is preceded by private access specifier. For example, below class has a private…

Read the full article

Design thread safe Singleton Class in C# Considering Performance

In, C# programming, Singleton in multi-threaded environment can produce more than one objects of singleton class if not designed properly. Where singleton class is expected to return only one of its instance. In this section, we will design the thread safe singleton class which was not designed in the answer of C# technical interview question…

Read the full article

How to Create Custom Exception in C# .net program? Use of it?

Implementation of user defined or custom exception in C# .net programming is simple and is implemented by extending system Exception class. We’ll answer concept of run time custom exception with a program example in C#. Custom Exception Class Custom Exception class is nothing but a user defined class which is derived from System Exception class.…

Read the full article

Advantage of Immutable String in C# programming

Advantage of immutable string in C# programming is data security. Let’s understand benefits of immutable string with a C# program example. Recommended to read immutable and mutable string in C# program. Here is the scenario, Main() program has a String msg = “Hello World”; and will call Display1()and then Display2()method. Display1()method will read the string…

Read the full article

Write code to retrieve data from SQL database in C# asp net

Here are the steps to connect SQL database server, access database and retrieve data from a table programmatically in C# asp net. Steps: Create an object of SqlConnection class Prepare connection string for SqlConnection class object. Create object of SqlCommand class and prepare sql command with types, queries and sql connection object. Open sql connection…

Read the full article

1 Scenario where C# interface is indispensable?

Interview Question: Tell one scenario where C# interface is indispensable. For the scenario, only C# interface is the solution and abstract class cannot be used. Answer: Scenario is multiple interface inheritance. C# object oriented programming does not support multiple class inheritance, means, a class cannot inherit more than one class in C#. But, a class…

Read the full article

What to choose between C# interface and abstract class?

Problem statement: If C# Interface and abstract class in a program, both contains only method declaration (C# source code shown below) then what would be your best choice between interface and abstract class and why? Note that abstract class will not contain any other method implementation. Below is the Interface and abstract class declaration and…

Read the full article