Interview Questions

AJAX Interview Questions Android Interview Questions Angular 2 Interview Questions AngularJs Interview Questions Apache Presto Interview Questions Apache Tapestry Interview Questions Arduino Interview Questions ASP.NET MVC Interview Questions Aurelia Interview Questions AWS Interview Questions Blockchain Interview Questions Bootstrap Interview Questions C Interview Questions C Programming Coding Interview Questions C# Interview Questions C++ Interview Questions Cakephp Interview Questions Cassandra Interview Questions CherryPy Interview Questions Clojure Interview Questions Cobol Interview Questions CodeIgniter interview Questions CoffeeScript Interview Questions Cordova Interview Questions CouchDB interview questions CSS Buttons Interview Questions CSS Interview Questions D Programming Language Interview Questions Dart Programming Language Interview Questions Data structure & Algorithm Interview Questions DB2 Interview Questions DBMS Interview Questions Django Interview Questions Docker Interview Questions DOJO Interview Questions Drupal Interview Questions Electron Interview Questions Elixir Interview Questions Erlang Interview Questions ES6 Interview Questions and Answers Euphoria Interview Questions ExpressJS Interview Questions Ext Js Interview Questions F# Interview Questions Firebase Interview Questions Flask Interview Questions Flex Interview Questions Fortran Interview Questions Foundation Interview Questions Framework7 Interview Questions FuelPHP Framework Interview Questions Go Programming Language Interview Questions Google Maps Interview Questions Groovy interview Questions GWT Interview Questions Hadoop Interview Questions Haskell Interview Questions Highcharts Interview Questions HTML Interview Questions HTTP Interview Questions Ionic Interview Questions iOS Interview Questions IoT Interview Questions Java BeanUtils Interview Questions Java Collections Interview Questions Java Interview Questions Java JDBC Interview Questions Java Multithreading Interview Questions Java OOPS Interview Questions Java Programming Coding Interview Questions Java Swing Interview Questions JavaFX Interview Questions JavaScript Interview Questions JCL (Job Control Language) Interview Questions Joomla Interview Questions jQuery Interview Questions js Interview Questions JSF Interview Questions JSP Interview Questions KnockoutJS Interview Questions Koa Interview Questions Laravel Interview Questions Less Interview Questions LISP Interview Questions Magento Interview Questions MariaDB Interview Questions Material Design Lite Interview Questions Materialize CSS Framework Interview Questions MathML Interview Questions MATLAB Interview Questions Meteor Interview Questions MongoDB interview Questions Moo Tools Interview Questions MySQL Interview Questions NodeJS Interview Questions OpenStack Interview Questions Oracle DBA Interview Questions Pascal Interview Questions Perl interview questions Phalcon Framework Interview Questions PhantomJS Interview Questions PhoneGap Interview Questions Php Interview Questions PL/SQL Interview Questions PostgreSQL Interview Questions PouchDB Interview Questions Prototype Interview Questions Pure CSS Interview Questions Python Interview Questions R programming Language Interview Questions React Native Interview Questions ReactJS Interview Questions RequireJs Interview Questions RESTful Web Services Interview Questions RPA Interview Questions Ruby Interview Questions Ruby on Rails Interview Questions SAS Interview Questions SASS Interview Questions Scala Interview Questions Sencha Touch Interview Questions SEO Interview Questions Servlet Interview Questions SQL Interview Questions SQL Server Interview Questions SQLite Interview Questions Struts Interview Questions SVG Interview Questions Swift Interview Questions Symfony PHP Framework Interview Questions T-SQL(Transact-SQL) Interview Questions TurboGears Framework Interview Questions TypeScript Interview Questions UiPath Interview Questions VB Script Interview Questions VBA Interview Questions WCF Interview Questions Web icon Interview Questions Web Service Interview Questions Web2py Framework Interview Questions WebGL Interview Questions Website Development Interview Questions WordPress Interview Questions Xamarin Interview Questions XHTML Interview Questions XML Interview Questions XSL Interview Questions Yii PHP Framework Interview Questions Zend Framework Interview Questions

Top 48 C# Interview Questions for 2022

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:
private protected throw void
readonly ref true unchecked
return public while typeof
sealed this sbyte unsafe
short switch sizeof ulong
static struct ushort uint
string stackalloc volatile virtual
Contextual Keywords:
alias get orderby set
ascending group partial (type) add
descending into partial(method) select
dynamic join remove from

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



ADVERTISEMENT
ADVERTISEMENT