C# interview questions and answers

Below are a few C# interview questions and answers which will be helpful to clear interview in C#.Net.

C# interview questions and answers

What is C#.Net (C-Sharp)?

  • C# is a new language created by Microsoft and submitted to the ECMA for standardization.
  • According to Microsoft “C# is a modern, object-oriented language that enables programmers to quickly build a wide range of applications for the new Microsoft .Net platform, which provides tools and services that fully exploit both computing and communications.”

What are the characteristics of C#.Net?

C#.Net is designed for both computing and communication is characterized by several key features. It is –

  • Simple
  • Consitent
  • Modern
  • Object-oriented
  • Type-safe
  • Versionable
  • Compatible
  • Interoprable
  • Flexible

What is BOXING and UNBOXING in C#.Net?

BOXING in C#.Net is the conversion of a VALUE type on the stack to an OBJECT type on the heap. Vice-versa the conversion from an OBJECT type back to a VALUE type is known as UNBOXING and it requires typecasting.

In how many ways you can create new copies of an existing string in C#.Net?

There are two ways:

  • Using overloaded = operator like strings2=s1;
  • Using the static Copy method like – string s2 = string.Copy(s1);

Which collection class uses the unique key for the collection?

HashTable

What is thread?

It is a process which executes independently.

Can interface have static member?

No.

Can constructors have access specifier ?

Yes

How do I launch Internet Explorer in C#.Net?

using the statement – System.Diagnostics.Process.Start(“IExplore.exe”,http://www.google.com);

Is it possible to have a static indexer in C#.Net?

No, they are not allowed in C#.Net.

Are constructors inherited in C#.Net?

No, constructors are not inherited.

How is method overriding different from method overloading?

When overriding a method, you change the behavior of the method for the derived class. Overloading a method simply involves having another method with the same name within the class.

Does C#.Net do array bounds checking?

Yes. An IndexOutOfRange exception is used to signal an error.

What happens in memory when you Box and Unbox a value-type?

  • Boxing converts a value-type to a reference-type, thus storing the object on the heap.
  • Unboxing converts a reference-type to a value-type, thus storing the value on the stack.

How do you convert a value-type to a reference-type?

By Using Boxing.

C#.Net Interview Questions

Here are few more C#.Net interview questions.

  • What is CLR?
  • What is the difference between managed and unmanaged code?
  • What is GAC?
  • What is CTS and CLS in C#.Net?
  • What are boxing and unboxing in C#.Net?
  • What are generics?
  • What is Abstraction, encapsulation, inheritance, and polymorphism?
  • What is difference between abstract class and interface?
  • What is the Difference between NameSpace and Assembly?
  • What is the use of strong names?
  • What is the difference between Convert.toString and .toString () method?
  • What is the difference between ArrayList and the list?
  • Where are the types of arrays in C#?
  • What are the types of access modifiers in C#?
  • What is the difference between const and read-only in C#?
  • What is the difference between out and ref in C#?
  • What is hashtable in C#.Net?
  • What are the hashtable collections?
  • What are Constructors and destructors?
  • What is a delegate in C#.Net?
  • How can we create a delegate?
  • What is a multicast delegate?
  • What are Events?
  • What is the difference between delegates and events?
  • What is shadowing?
  • What is the difference between Shadowing and Overriding?
  • What does the virtual keyword mean?
  • What is Enum?
  • What is Indexer?
  • Can we have a static indexer in C#?
  • What is .NET Remoting?
  • What is a Web Service?
  • What’s the difference between web services and remoting?
  • What is UDDI?
  • What is DISCO?
  • What is WSDL?
  • What are the steps to create a web service and consume it?
  • How do we secure a web service?
  • What’s the difference between WCF and Web services?
  • What are endpoints, contracts, addresses, and bindings in WCF?
  • What is a service contract, operation contract and Data Contract in WCF?
  • What are the various ways of hosting a WCF service?
  • How do we host a WCF service in IIS?

WCF interview questions in C#.Net

Below are few C#.Net WCF interview questions.

  • What is WCF?
  • What is the advantages of WCF over web service in C#.Net?
  • What are the main components of WCF?
  • What are addresses, bindings, and contracts in WCF?
  • What is the endpoint in WCF?
  • What is a service contract, operation contract, and Data Contract?
  • What are the different bindings supported by WCF?
  • What is the difference between BasicHttpBinding and WsHttpBinding?
  • What are the various ways of hosting a WCF service?
  • How to host WCF in IIS?
  • How to do self-hosting a wcf service?
  • How to host a WCF service in windows service in C#.Net?
  • How can we generate WCF proxy using SVCUtil.exe?
  • What is the work of SvcUtil.exe?
  • What are the advantages of hosting WCF Services in IIS as compared to self-hosting?
  • How can we enable debugging and tracing on WCF services?
  • How are exceptions thrown in WCF?
  • What is the difference between WCF fault exceptions and .NET exceptions?

C#.Net Windows Form interview questions

  • How to show a message box in the C#.Net windows application?
  • What is the difference between Debug, Write and Trace in C#.Net?
  • What is the difference between Show() and ShowDialog() in windows application?
  • How do we use event handlers in threading in C#.Net?
  • What’s the difference between a process and a thread?
  • What are asynchronous callbacks in delegates?
  • What are the Multi-cast delegates in C#.Net?
  • Difference between events and delegates in C#.Net?
  • What is the difference between Dispose and finalize in C#.Net?
  • What is serialization in C#.Net?
  • What are CLS and CTS in C#.Net?
  • What is the difference between Shadowing and Overriding?
  • How can I run an EXE from one application?
  • What does it mean by docking of controls in C#.Net?
  • What base class do all Winforms inherit from?
  • What is the difference between out and ref in C#.Net?

You may like following interview questions and C#.Net tutorials:

Here, we checked various C#.Net interview questions and answers.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>