C# Interview Questions

Hello guys, this post is about the interview questions that are asked by most of the interviewers. It contains beginners to expert level questions.  I have collected these questions from multiple websites and some personal experiences. Hope you will like this post.

Interview questions over this blog post is also good click here to view.

Interview Questions:

  1. benefit of linq
  2. example ref and out.
  3. difference between Application object and session object and temp data
  4. difference between Iqueryable ,Ienum and Icollection.
  5. difference API response based on  platform. (eg: mobile device: Json nd web app: xml)
  6. what are the serializer for json and xml.
  7. deferred object in angular
  8. services and factory in angular
  9. State Management Techniques
  10. Can a class have both static constructor and normal constructor. & which one is called first.
  11. Can a static class have non-static constructor.
  12. Boxing and unboxing example.
  13. Viewstate and where it is stored.
  14. Encapsulation and abstraction . example and how to use in c#.
  15. Association , composition and aggregation
  16. Multiple abstract class inheritance possible?
  17. can we create object of abstract class.
  18. difference between abstract and interface.
  19. dataview and datatable
  20. truncate and delete
  21. remove duplicate records.
  22. throw and throw ex : Answer: Throw will rethrow original exception;throw ex will create a new exception, so the stack trace changes.
  23. multiple ways of hosting wcf
  24. viewstate and where it is stored.
  25. Abstract class have constructor or not? If yes then why we cant instantiate it.
  26. DDL and DML commands
  27. Satellite assembly.
  28. Hashtable Vs Dictionary : * a Dictionary is a hash table*  Dictionary is a generic type, Hashtable is not. That means you get type safety with Dictionary, because you can’t insert any random object into it, and you don’t have to cast the values you take out. And also generic collections are a lot faster as there’s no boxing/unboxing.
  29. How to Set Master Page dynamically? : void Page_PreInit(Object sender, EventArgs e)


   this.MasterPageFile = “~/MyMaster.master”;


Explanation: You can attach a master page dynamically to a content page. Because the master page and content page are merged during the initialization stage of page processing, a master page must be assigned before then. Typically, you assign a master page dynamically during the PreInit stage


An interface is a contract: The guy writing the interface says, “hey, I accept things looking that way”, and the guy using the interface says “OK, the class I write looks that way”.

An interface is an empty shell. There are only the signatures of the methods, which implies that the methods do not have a body. The interface can’t do anything. It’s just a pattern

Abstract Classes:

Abstract classes look a lot like interfaces, but they have something more: You can define a behavior for them. It’s more about a guy saying, “these classes should look like that, and they have that in common, so fill in the blanks!”.

  =>Methods and members of an abstract class can be defined with any visibility, whereas all methods of an interface must be defined as public (they are defined public by default).

  =>hen inheriting an abstract class, a concrete child class must define the abstract methods, whereas an abstract class can extend another abstract class and abstract methods from the parent class don’t have to be defined.Similary interface.

  =>A child class can only extend a single class (abstract or concrete), whereas an interface can extend or a class can implement multiple other interfaces

  => A  child class can define abstract methods with the same or less restrictive visibility, whereas a class implementing an interface must define the methods with the exact same visibility (public)

  1. Design Patterns: a design pattern is a general repeatable solution to a commonly occurring problem in software design.Design patterns can speed up the development process by providing tested, proven development paradigms.

Types: creational, structural , behavior

creational: abstract factory, builder , factory method,object pool, prototype,singleton

structural: adapter, bridge,facade, flyweight,proxy.

31: State Management in asp.net: Server side: session Generally session is used to store user’s information and/or uniquely identify a user (or say browser). The server maintains the state of user information by using a session ID. and application :the date stored in application state is common for all users of that particular ASP.NET application and can be accessed anywhere in the application. It is also called application level state management. Data stored in the application should be of small size.

  1. Dynamic loading of Ui.
  2. Claims Authentication
  3. Model and ViewModel : how would you ignore particular property from being inserted into DB
  4. static class cannot be marked sealed because it is made sealed by compiler by default. Static classes are sealed and therefore cannot be inherited.
  5. static class cannot be marked as abstract, because it would be pointless. abstract class makes sense when you want all derived classes to implement same part of the logic. But because static class cannot be derived there is no way other class will implement these gaps. They cannot inherit from any class except Object
  6. Partial Classes and Parital Methods:(can only be implemented once.)
  7.  Jb tk override use ni karenge tb tk base class function change ni ho skta and new keyword is only to tell compiler to hide the implementation of base class to derived class.
  8. Use AllowAnonymous if u dont want action to be Authroized.
  9. Difference between == and equals? Ans:  Equals compares values(i.e, contents are same or not) , while == compares object references . My rule of thumb is that for almost all reference types, use Equals when you want to test equality rather than reference identity. But with string dataType both will do content comparison.
  1. what problem does delegate solves :

Ans. By defining a delegate, you are saying to the user of your class, “Please feel free to assign, any method that matches this signature, to the delegate and it will be called each time my delegate is called“. Laymen language: delegate is a representative to communicate between 2 parties. The real use of delegates in C# is callbacks.  

  1. Difference between var and dynamic:  var is compile time and dynamic is runtime.
  2. Difference between dispose and finalize.
  3. Difference between model and view model?
    Ans:  A Model is an object that we use to send information to the database, to perform business calculations and to render a view .ViewModel in the MVC design pattern is very similar to a “model”. The major difference between “Model” and “ViewModel” is that we use a ViewModel only in rendering views. We put all our ViewModel classes in a “ViewModels” named folder, we create this folder.
  4. Difference between 3-tier and 3-layer architecture.
  5. Difference  between promise and observable.
  6. MVC request lifecycle and pagelifecycle.
  7. What is web api content negotiation? the process of selecting the best representation for a given response when there are multiple representations available. “Content Negotiation” means the client and server can negotiate. It’s not always possible for the server to return data in the requested format. That’s why it’s called negotiation, not demand. Ha.Ha.. And in this case the service will return data in the default format.
    The question is, how does the Web API know what the clinet expects? By checking below the header of the request object.
    Content-type:, Accept: , Accept-Charset: , Accept-Encoding: ,Accept-Language:
  8. Global.asax? And different methods inside it?
  9.  What happen between OnResultExecuting and OnResultExecuted?
  10.  Different types of ActionResult?
  11. Use of Partial Class
  12. What is managed code and How can we identify which code is managed code
  13. Example of encapsulation and abstractions
  14. Architecture of application
  15. Design Principle
  16. Runtime vs compile time polymorphism
  17. What are the differences between events and delegates in C#?

  18. difference-between-localstorage-sessionstorage-session-and-cookies
  19. Exception Handling in MVC
  20. Return different view if we have exception filter based on role.
  21. System.Object vs dynamic

  22. Why base class instance can not be stored in derived class reference?

  23. AppDomain?

  24. Threads vs process

  25. large/small object heap in c#?

  26. ES6 benefits

  27. modelbinders asp.net mvc

  28. New html5 features in JS

  29. https options used for ?

  30. Angular existing services example other than http

  31. Can we have multiple ng-app in SPA?

  32. Challenging thing you have ever done , like extending some support in library?

  33. Can we have child class having default constructor and parent class have only parameterized constructor only?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s