Below are some of the most commonly asked questios in C#:
Q. What is the difference between a const and readonly in C#?
A. Refer: Const vs Readonly
Q. What is the difference between out and ref keywords?
A. Refer: Difference between out and ref parameters
Q. What is the difference between an Array & ArrayList?
A. Refer: Difference between an Array and ArrayList
Q. Which namespace is the base class for all .Net Class Libraries?
Q. What is boxing and unboxing?
A. Refer to: Boxing and Unboxing in C#
Q. What is the difference between a thread and a process?
A. Refer: Thread vs Process
Q.What are the different access modifiers in C#?
A. Below are the available access modifiers and their scope details.
a. Public: Access not limited.
b. Protected: Access limited to the containing class or types derived from the containing class.
c. Internal: Access limited to current project.
d. Protected Internal: Access limited to the project or types derived from the containing class.
e. Private: Access limited to the containing type.
Q. Strings are immutable, what does it mean?
A. Strings are immutable, it means if strings are once created, they cannot be changed. Although some string operation methods seem to modify string content, but .Net framework creates a new string with the new value. The original string remains unchanged.
Refer: MSDN for more details.
Q. What are User-defined types? How to create them?
Q. What are Partial Classes?
A. Refer to: Partial Class in .Net
Q. What is the difference between Finalize & Dispose?
A. Refer: Finalize vs Dispose
Q. What is a ternary operator?
A. Refer to: Ternary Operator
Q. What is the difference between CopyTo() and Clone() methods in System.Array?
A. Clone() creates another array with the exact copy as original array. It returns an exact length array. CopyTo() copies the elements from the original array to an another existing array starting at the specified existing array index.
Q. What is a Windows Service? What are the steps to create it?
A. Windows Service is an executable that runs at the background in its own session and performs specific functions.
Refer this link for: Steps to Creating a Windows Service
Q. What are generics?
Q. What is an Event? How to raise it?
Q. What is a delegate?
A. Refer to: Delegates in C#
Q. What is a multicast delegate?
Q. What is Type Forwarding?
Q. What is the difference between a Struct and a Class?
A. Refer: Struct vs Class
Q. What is the difference between method overloading and overriding?
A. Refer: Overloading vs Overriding
Q. What is the difference between an Abstract Class and Interface?
A. Refer: Abstract Class vs Interface
Q. What are sealed classes in c#?
A. Sealed classes are used to restrict inheritance. In C#, the sealed modifier is used to make the class as sealed. No other class can be derived using the sealed class.
A compile-time error occurs if the sealed class is specified as the base class of a class.
// Sealed class
sealed class ClassA
//define data members & methods.
Read on Sealed Methods in this nice article: Sealed Methods
Q. What are indexers? How they are different from properties?
A. Refer to: Indexers in c#
Q. Can abstract class have non-abstract methods?
A. Yes. The abstract class can contain abstract and non-abstract methods.
Q. What is inheritance?
A. Refer: Inheritance in C#
Q. What is polymorphism?
A. Refer: Polymorphism in C#
Q. What is the difference between typed and instance constructor?
A. Refer: Difference between Typed and Instance Constructor
Q. How to create and send HTML E-Mail Message?
A. The class used to create an E-Mails in .net is MailMessage. It is
contained in System.Web.Mail namespace. Check the below code to create
and send HTML emails using c#.
MailMessage testMail = new MailMessage();
testMail.To = "email@example.com";
testMail.From = "firstname.lastname@example.org";
testMail.Subject = "Hello World!";
testMail.BodyFormat = MailFormat.Text;
testMail.Body = "Check out the attachment!";
Q. What are the types of collections available in .net?
A. Refer: Types of collections in .net
Q. What are Sequential Lists? What are its types?
A. Refer: Sequential Lists in C#
Q. What is Serialization?
Q. How to Serialize and Deserialize an object (using Binary & XML Formatter)?
Q. What are different types of serialization? Which one to choose & when?
Q. What are different types of attributes used in serialization using Binary Formatter?
Q. What are different types of attributes used in serialization using XML Formatter?
Q. What are the different Serialization Events?
Q. What is an Application Domain?
Q. How to load/unload assemblies in an Application Domain?
Q. What is an Event Log? Q. How to Create/Delete an Event Log? Q. How to Read/Write from an Event Log?
A. Refer to: Managing EventLogs in Event Viewer using .Net
Q. What is debugging? What are various debugging techniques that help debugging an issue quickly?
A. Refer: Debugging and its techniques
Q. What is MSMQ? How to create queues? How can applications send and receive messages from queues?
A. Refer: Message Queuing - MSMQ
Q. What are different logical and physical layers in n-tier architectures?
A. Logical Layers:
1. UI - This layer is a presentation layer with which the client interacts.
2. MT - This is a Middle-Tier layer which contains the main code & business functionality.
3. DB - This is a database layer that contains the actual data.
1. UI - This could be either a browser (web application), windows client (windows application), dos windows (console based application) or any other interface with which users can interact with.
2. MT - This could be DLLs/Libraries, WebServices, WCF etc.
3. DB - This could be SQL Server, Oracle or some other database.