×

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 18 Blockchain Interview Questions and Answers for 2024

Top 20 Commonly Asked Blockchain Interview Questions and Answers 1. What do you understand by Blockchain? Blockchain is a chain of blocks made up of digital pieces of information or can be defined as...

6 minutes read.

Top 15 PostgreSQL Interview Questions for 2024

1) What is PostgreSQL? PostgreSQL is a most advance open source database system. PostgreSQL is an object Oriented Relational Database Management System (ORDBMS). PostgreSQL source code is available free of charge...

3 minutes read.

Artificial Neural Network Interview Questions

1. Explain Neural Network?  Neural Network is a sequence of an algorithm that gives its best to recognize the underlying relationship in a data-set through a process. The artificial neural network...

8 minutes read.

Top 25 PL/SQL Interview question for 2024

1) What is PL/SQL? It is defined as SQL having Procedural features of Programming Language i.e. Procedural Language extension of SQL. 2) Enlist the section of PL/SQL block. It consist of three block ...

4 minutes read.

Top 15 Bootstrap Interview Questions for 2024

1) Explain what is Bootstrap? It is a Framework which is used for building the web application with minimal effort. Bootstrap is also used for developing responsive, mobile-first web sites. 2) What...

10 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 15 VBA Interview Questions for 2024

1) What is VBA? VBA stands for Visual Basic Application. It is an event-driven programming language. It is mainly used with Microsoft Office applications such as MS -Excel, MS-Word and MS-Access. 2)...

3 minutes read.

Flutter Interview Questions

Here’s a list of top Flutter questions that are frequently asked. Q1.  Is Flutter an open-source? A1.  Yes, Flutter is a 100% open-source software development kit. Q2.  What are flutter widgets? A2.  Widgets are...

7 minutes read.

Top 30 CSS Interview Questions for 2024

1) Define the process where block elements can be centered with css. It can be centered by using margin-left and margin-right properties we can centered the block level elements. 2) Name the...

4 minutes read.

Top 15 Xamarin Interview Questions for 2024

1) What is Xamarin? Xamarin is a .NET framework. It allows to create an application that run on multiple platforms. Xamarin Tutorial uses C# language and .NET framework to deliver native...

2 minutes read.

Top 30 Ruby on Rails Interview Questions for 2024

1) What is Ruby on Rails? It is a server-side web application framework. It is an open source ruby framework which is used for developing database-backed web applications. Here, no compilation phase is...

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.

W3.CSS Interview Questions

1) What is W3.CSS? W3.CSS stands for Cascading Style Sheet. It is developed by w3schools.com. It is used to create faster, beautiful and responsive websites. 2) What are the features of W3.CSS? W3.CSS...

3 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.

Top 25 Android Interview Questions for 2024

1) What is Android? It is a software package and open-source operating system that is used in mobile devices. It is also a Linux kernel-based system operating system and application executes within...

3 minutes read.

Top 14 Elixir Interview Questions for 2024

1) What is Elixir? Elixir is a dynamic, functional language. It is designed to build scalable and maintainable applications. 2) Who developed Elixir? Ericsson developed elixir in 1986. 3) What is the stable version of...

2 minutes read.

Top 30 SQL Interview Questions for 2024

1. What is SQL? Ans. SQL stands for Structured Query Language.  It is a standard computer language for accessing, storing, and manipulating data stored in the relational database. SQL become an International Standard Organization (ISO)...

11 minutes read.

Top 15 Cordova Interview Questions for 2024

Top 20 Cordova Interview Questions and Answers for Freshers 1) What is Cordova? Cordova is a mobile application development framework. Cordova allows building mobile application using HTML5, CSS3, and JavaScript. Cordova is...

3 minutes read.

Top 30 AJAX Interview Questions for 2024

1) What is AJAX? AJAX (Asynchronous JavaScript and XML) create better, faster and interactive web-apps. It provides data transfer between web-server and browser. 2) List some advantages of AJAX Advantages are: More Interactive: Very...

3 minutes read.

Top 15 Ext Js Interview Question for 2024

1) What is Ext Js? Ext Js refers to Extended JavaScript. Ext JS is a JavaScript framework used to built interactive cross platform web application. 2) What are the features of Ext...

3 minutes read.