×

Top 48 C# Interview Questions for 2024

1) Write a program in C# to print "HELLO WORLD"?

class Program    

    {    

     static void Main(string  args[])    

      {    

        System.Console.WriteLine(" HELLO WORLD ");    

        }    

     }

2) Write a program in C# to print "TutorialandExample" using namespace?

Here, namespace is used to group related classes.
Using System;  

 namespace  TutorialandExample    

 {    

    public class     

     {    

        public static void Main(string[]  args)    

        {    

         Console.WriteLine(" TutorialandExample ");    

        }    

     }    

  }

3) What are the types of C# operators?

The types of C# operators are:
  • Arithmetic Operators
  • Logical Operators
  • Relational Operators
  • Bitwise Operators
  • Unary Operators
  • Assignment Operators
  • Ternary Operators
  • Misc Operators

4) Write a program in C# to check the number is EVEN or ODD?

using System;        

public class ODDorEVEN    

{    

 public static void Main(string args[])    

 {    

 int num =  10;    

 if (num % 2 == 0)    

 {    

  Console.WriteLine("It is even number");    

  }    

  else    

  {    

  Console.WriteLine("It is odd number");    

  }    

 }    

 }

5) What are the types of Generic delegates in C#?

There are three types of Generic delegates in C#:
  • Action
  • Func
  • Predicate

6) What are the types of comment in C#?

There are three types of comment in C#:
    • Single line.
Example: // Single Line Comment.
    • Multiple line.
Example: /* Multiple Line Comment.*/
    • XML comments.
Example: /// XML Comment.

7) What is difference between "is" and "as" operators in c#?

Difference between "is" and "as" operators in C# is: is operator: It is used to check the compatibility of an object. It returns the result as Boolean. as operator: It is used for casting of object to a type.

8) What are the different types of constructors in C#?

There are five types of constructor in C#:
  • Copy constructor
  • Static constructor
  • Private constructor
  • Parameterized constructor
  • Default constructor

9) What is the use of Break statement in C#?

C# Break: It is used to break loop or switch statement. Example of Break statement:
using System;    

public class BreakExam    

    {    

      public static void Main(string args[])    

      {    

          for (int i = 1;  i <= 10;  i++)    

          {    

              if (I  ==  4)    

              {    

                  break;    

              }    

              Console.WriteLine(i);    

          }    

      }    

   }

10) What will be the output of the following code snippet?

using System;    

namespace Application1  {    

class Areaa   {    

static void Main(string[] args)   {    

const int length = 12;  

const int breadth = 10;  

 int area=length * breadth;  

Console.WriteLine("Area : {0}",area);   }      

} }

11) What is the name of a method which has the same name as that of class and used to destroy objects?

Destructor.

12) List out the characteristics of C#?

The characteristic of C# is:
  • Compatible
  • Simple
  • Consistent
  • Type safe
  • Scalable and Updateable
  • Interoperability
  • Object oriented
  • Modern programming language

13) Name the applications created by the C# .NET?

The applications created by C# .NET are:
  • Web applications.
  • Console applications.
  • Web services.
  • Windows applications.

14) What are the features of namespace?

The features of namespaces are:
  • They are implicitly public.
  • It is not a type.
  • The interfaces, classes, enums, struts and delegates are allowed.
  • It may be nested.

15) What are the types of literals supported by C#?

The types of literals supported by C# are:
  • Single character literals
  • Integer literals
  • String literals
  • Boolean literals
  • Real literals
  • Backslash character literals

16) What is C#?

C# is an object oriented programming language. It is a type-safe and managed language that is compiled by .NET framework.

17) What are the features of C#?

The features of C# are:
  • Indexers
  • Standard Library
  • Boolean Conditions
  • Assembly Versioning
  • Easy-to-use Generics
  • Properties and Events
  • Simple Multithreading
  • Conditional Compilation
  • Integration with Windows
  • LINQ and Lambda Expressions
  • Automatic Garbage Collection
  • Delegates and Events Management

18) What are the advantages of C#?

The advantages of C# are:
  • Easy to learn
  • Component oriented
  • structured language
  • object oriented language
  • Part of .Net Framework
  • It produces efficient programs
  • Compiled on a variety of computer platforms

19) Who is the developer of C#?

Anders Hejlsberg is the developer of C#.

20) Name some of the components of the .Net framework?

The components of the .Net framework are:
  • LINQ
  • ADO.Net
  • Windows Forms
  • Common Type System
  • Metadata and Assemblies
  • ASP.Net and ASP.Net AJAX
  • Common Language Runtime
  • Windows Workflow Foundation
  • Common Language Specification
  • Windows Presentation Foundation
  • Windows Communication Foundation
  • The .Net Framework Class Library

21) What are the different types of IDE available for C#?

The different types of IDE available for C# are:
  • Visual Studio 2010
  • Visual Web Developer
  • Visual C# 2010 Express

22) How to compile a C# program by using command-line?

For Compile: Type csc FileName.cs in the command prompt.

23) What is the extension supported by C#?

C# supports .cs extension only.

24) What is "using" in C#?

using is a keyword that is used for including the namespaces in the program. It is the first statement in any C# program.

25) What are the reserved keywords and contextual keywords available in C#?

The reserved keywords and contextual keywords available in C# are: Reserved Keywords:privateprotectedthrowvoidreadonlyreftrueuncheckedreturnpublicwhiletypeofsealedthissbyteunsafeshortswitchsizeofulongstaticstructushortuintstringstackallocvolatilevirtual Contextual Keywords:aliasgetorderbysetascendinggrouppartial (type)adddescendingintopartial(method)selectdynamicjoinremovefrom

26) What are the types of variables used in C#?

The types of variables used in C# are:
  • Value types
  • Pointer types
  • Reference types

27) What is the use of "sizeof" method in C#?

sizeof method is used to get the exact size of a type or a variable on a particular platform.

28) What is Object Type?

Object Type: It is the base class of all data types in C# CTS (Common Type System).

29) What is boxing?

boxing: When a value type is converted to object type.

30) What is unboxing?

unboxing: When an object type is converted to a value type.

31) What is Type Casting?

Type Casting: It is used for converting one type of data to another type. There are two forms of Type Casting are:
  • Implicit type conversion
  • Explicit type conversion

32) How to convert value types into String type in C#?

Example:
using System;  

namespace TutorialandExample   

{  

 class Atul  

{  

static void Main(string[] args)  

{  

int i = 12;  

float f = 73.005f;  

double d = 2545.9652;  

bool b = true;  

  

Console.WriteLine(i.ToString());  

Console.WriteLine(f.ToString());  

Console.WriteLine(d.ToString());  

Console.WriteLine(b.ToString());  

Console.ReadKey();  

              

}  

}  

}
OUTPUT:
12
73.005
2545.9652
True

33) What is the syntax for declaring nullable data types?

Syntax for declaring nullable data types are:
  1. < data_type>? <variable_name> = null;

34) What are nullable types?

nullable types: It is a special type of data type that is used to assign normal range of values as well as null values.

35) What is Null Coalescing Operator?

Null Coalescing Operator: This operator is used for converting an operand to the type of another nullable value type operand. This operator is used with the nullable value types and reference types. The Null Coalescing Operator is denoted by: ??.

36) Can we return multiple values from a function in C#?

Yes, we can return multiple values from a function by using output parameters.

37) Which class acts as a base class for all arrays in C#?

The Array class is acts as a base class for all arrays in C#.

38) Can we use multiple inheritance in C#?

No.

39) What is early binding?

early binding: It is the mechanism of linking a function with an object during compile time. It is also known as static binding.

40) Which class acts as a base class for all the data types in .net?

Object Type is the base class for all data types in .net.

41) In how many ways you can pass parameters to a method?

Three ways to pass parameters to a method are:
  • Value parameters
  • Output parameters
  • Reference parameters

42) How the exception handling is done in C#?

By using try…catch block.

43) Can we execute multiple catch blocks in C#?

No.

44) Can we override private virtual method in C#?

No.

45) What are the types of delegates in C#?

The types of delegates in C# are:
  • Single Delegate
  • Generic Delegate
  • Multicast Delegate

46) How encapsulation is implemented in C#?

By using access specifiers.

47) Which method is used to sort an array in C#?

By using Array.sort(array) function.

48) What are the Predefined Attributes of .Net framework?

There are three Predefined Attributes of .Net framework are:
  • Obsolete
  • Conditional
  • AttributeUsage

Related Topics

Top 15 JavaFX Interview Questions for 2024

1) What is JavaFX? JavaFX is a software platform for creating desktop applications or internet application. It uses java library. It can run various devices such as Desktop Computer, Mobile, TVs...

3 minutes read.

Bugzilla interview Questions

Frequently asked questions about Bugzilla Q1. What are reports in Bugzilla? A1. Reports can be defined as an interface between the user and the database of Bugzilla. It helps to examine and...

4 minutes read.

Top 30 Perl interview questions for 2024

1) What is Perl? It is a programming language which is used for web development, system administration, GUI development and etc. It is also known as cross-platform programming language. 2) What are the...

4 minutes read.

Top 25 Oracle DBA Interview Question for 2024

1) What is an Oracle Instance? Database instance is a set of memory structures that manages database file. When an instance is started Oracle database allocate memory area called SGA (System...

4 minutes read.

Top 25 CoffeeScript Interview Questions for 2024

1) What is CoffeeScript? It is a language that compiles into JavaScript. CoffeeScript is an attempt to expose good parts of JavaScript so, that user can code more easily. 2) Name the...

3 minutes read.

Top 30 Swift Interview Questions for 2024

1) What is Swift? It is an innovative programming language developed by Apple Inc. It is used for creating applications for iOS and OS X. 2) What are the features of Swift Programming? Features...

4 minutes read.

Top 20 HTTP Interview Questions for 2024

1) What is HTTP? HTTP stands for Hypertext Transfer Protocol. It is a set of rules for transferring of data on WWW (World Wide Web). 2) What are the basic Features of...

4 minutes read.

Ember.js Interview questions

1) What is Ember.js? Ember.js is a JavaScript front-end Framework. It provides developer both features for managing complexity in modern web-apps as well as integrated development kit. 2) Why choose Ember.js? Logical...

2 minutes read.

Top 26 SEO Interview Questions for 2024

Most Frequently asked SEO Interview Questions and Answers for Fresher and Experienced 1) What is SEO? SEO stands for Search Engine Optimization. It is a set of processes followed by website owners...

4 minutes read.

Top 15 iOS (iPhone, iPad) Interview Questions for 2024

Top 20 Most Frequently asked iOS Interview Questions and Answers 1) What is iOS? iOS is a mobile operating system developed by Apple Inc. iOS offers iPhone and iPad application development using...

3 minutes read.

Top 15 Foundation Interview Questions for 2024

1) What is Foundation? Foundation is a front-end framework that is for designing beautiful responsive websites. This framework is compatible with all types of devices and provides you with HTML, CSS...

2 minutes read.

Top 30 RPA Interview questions for 2024

Q1. What is RPA (Robotic Process Automation)? The Robotic Process Automation is a trending technology in the market where: Robotic: Robotic means "machines that copy the human actions." Process: Process means "the sequence of steps which...

12 minutes read.

Top 16 WebGL Interview Questions for 2024

1) What is WebGL? WebGL stands for Web Graphics Library. It is a JavaScript API that is used for rendering 3D graphic in any compatible web browser. It is written in...

3 minutes read.

Top 10 WCF Interview Questions for 2024

  1. What is WCF? Windows Communication Foundation (WCF), earlier known by the name Indigo, is a run-time platform and a set of APIs in the .NET Framework for building, configuring, and...

7 minutes read.

C++ | C Plus Plus Interview Questions for 2024

1) Write a program in C++ to print "Hello World"? #include <iostream.h>     #include <conio.h>   void main()    {       clrscr();       cout << "Hello World";     getch();     } 2) Write a program in C++ to enter two integers and find their sum and average ? #include <iostream.h>   #include <conio.h>   void main()   {   clrscr();   int x,y;   float sum,average;   cout << "Enter 2 integers : " << endl;   cin>>x>>y;   sum=x+y;   average=sum/2;   cout <<"The sum is:"<< sum << endl;   cout <<"The average is:"<< average << endl;   getch();   } 3) Write a program in...

5 minutes read.

Top 15 CSS Buttons Interview Questions for 2024

1) What is CSS buttons? CSS buttons is used to create awesome button. It provides huge collection of CSS library files. 2) What are the CSS libraries to create buttons? There are following...

5 minutes read.

Top 15 NodeJS Interview Questions for 2024

1) What is NodeJs? NodeJs is open source JavaScript based feamework used to develop I/O intensive web application. It is collections of JavaScript library and runtime environment. It is used to...

3 minutes read.

Top 14 MathML Interview Questions for 2024

1) What is MathML? MathL stands for Mathematical Markup Language. It is extended form of XML. It is used to describe mathematical and scientific notations. 2) Who is the developer of MathML? World...

3 minutes read.

Top 15 ASP.NET MVC Framework Interview Questions for 2024

1) What is ASP.NET MVC Framework? ASP.NET MVC framework is a software architecture pattern for developing web applications. It is used to split the application's implementation logic into three components: models,...

4 minutes read.

SSRS Interview Questions

1. What is SSRS? The Microsoft SQL Server Reporting Service (SSRS) is a server-based reporting platform. It allows you to produce structured reports. The reports are generally represented in the form of data, graph,...

5 minutes read.