C#
1. Array List and Hash Table
- Data is stored in name value pair in hash table, where as in has in array list only value is stored.
- To access hash table only you need name, where as to access array list index is required.
- You can store different type of data in hash table, while only similar type of data is stoed in array list.
2. String builder and system.string
- system.string in immutable where as string builder is mutable
- append key word is used to add data in string builder but not in system.string
3. Application and Session object
- Session object is used to maintain the session of each user. If a user enters an application, a session id is created and when he leaves the id is deleted.
- Application object is used to maintain the id for whole application
4. Interface and Abstract Class
- Abstract class cannot be instantiated, but inherited where as interface can be.
- Abstract class contains class definitions and declaration, where as interface contains only declarations.
- A class which contains only abstract method is an interface class, where as a class which abstract method is an abstract class.
- Only public access specifier can be used in Interface, but abstract can have any access specifier
5. Boxing and Unboxing
- Boxing: Converting value type into reference type
- Unboxing: Converting reference type into value type
6. Level of state management
7. How to pass optional parameter in method.
There are two ways
- If you use C# version 4.0,then Optional parameter can be used by Assignment statement
public void SendCommand(String command, string strfilename=null)- By Using Param Keyword
8. Difference between out and Ref
- Out requires variable value to be SET before leaving the method.
- While ref does NOT require variable to set
9. What is a chain constructor?
Chain constructor is calling of one constructor from within the other. Say for example :
Chain constructor is calling of one constructor from within the other. Say for example :
public class mySampleClass
{
public mySampleClass(): this(10)
{
// This is the no parameter constructor method.
// First Constructor
}
public mySampleClass(int Age)
{
// This is the constructor with one parameter.
// Second Constructor
}
}
10. What is Lambda Expression?
It's a method without a declaration, i.e., access modifier, return value declaration, and name.
List<int> numbers = new List<int>{11,37,52};List<int> oddNumbers = numbers.where(n => n % 2 == 1).ToList();
11. What is a satellite assembly?
Satellite assemblies are assemblies that are used to deploy language and culture specific resources for an application.
12. Reflection
Used to decide at run time which method needs to be called depending upon the business logic.
object[] param = new object[4];
param[0] = xMetaData;
param[1] = shipment;
param[2] = ShipmentDataRaw;
param[3] = manifestHeader;
Type type = typeof(BL_ReportsCustom);
MethodInfo methodInfo = type.GetMethod(customMethodName);
BL_ReportsCustom method = new BL_ReportsCustom();
// Invoke the method on the instance we created above
methodInfo.Invoke(method, param);
13. Constructor and Destructor
static constructors are only executed when the first object of a class is created and are executed from child to parent.
Constructors are executed like parent to child way
Destructors are executed from child to parent way.
14. Idispose
15. Abstraction Vs Encapsulation
16. ref and value keyword. If a class object is passed as without ref keyword what happens
17. Threading? how to create thread.
18. Delegate
19. Event