#51 SOLID-Interface Segregation Principle
#50-SOLID -Liskov Substitution Principle
Liskov Substitution Principle: SubType (Child Class)Must be Substitutable For Base Type(Base Class).
LSP comes into use when you use inheritance/Abstraction.
Rules:
1.Child Class Should not remove Base Class Behaviour.
2.Child Class Should not violate base class invariants.
In short,the Calling code should not know whether it is calling the base class or derived class.

#49:SOLID-Open Closed Principle
#48 SOLID-Single Responsibility
#47: throwing Exception
you can throw exception in two ways.
1.throw. This will throw the caught exception.The throwed exception must be caught again.It will not reset the stack trace.
2.throw e or throw new CustomException : It behaves exactly same but it will reset the stack trace.
Experimentation of Throw vs Throw ex(throw new CustomException):
DivByZero Method:
private static void DivByZero()
{
int j = 0;
var result = 9/j; //Line No :45 in my program is the Cause of Exception
}
1.Throw:It does not reset the stack trace,instead preserves it and throws the exception
private static void thrwonigException(){
try
{
DivByZero();
}catch (DivideByZeroException e)
{
/*It will not reset stack trace,instead throws the caught exception */.
throw ;
}
}
It still maintains the line which causes the exception,
2.Throw e : Returns the line no 34 as cause of exception but not 45,the stack trace is reset after this line
private static void thrwonigException(){
try
{
DivByZero();
}
catch (DivideByZeroException e)
{
/*It will reset the stack trace and tells that this line is the cause of exception.
* It will not who caused the exception.
* */
throw e; //or throw new DivideByZeroException();
}
}
#46 Exception Handling Mechnaism
C# Provides try,catch and finally mechanism to handle Exception.
try: Business logic code block,potentially might cause exception
catch: Block where all your exceptions are caught.
Finally:Block which always executes after try/catch irrespective of exceptions.( P.S: Stackoverflow will make the finally block not to execute)
Rules:
1.There must be finally block after try,If you do not have a catch block.
2.There can be two or more catch blocks.
3.Ordering of Catching Exception Matters.
4.Exception is the base of all other ExceptionClasses.
try
{
/*your code here*/
}
catch(Exception exception)
{
/* Exeption caught if something goes wrong*/
}
finally
{
/*Guaranteed to run even if exception occurs.This block will always run*/
Console.WriteLine();
/*
* Clean UP Code.
*/
}
#45 What is AppDomain?
AppDomain is a mechanism where the application executes in Isolated Environment.
By Default,there is one AppDomain per process. A process may contain one or more AppDomain.
Any Exception or violation in One AppDomain will not affect other AppDomain or the process.
They are generally used when you load assembly to your current application.The loaded Assembly can be executed in separate AppDomain.
#44 SingleTon Pattern ?
1.It is essential when you need only one instance of a class.
2.The Class itself is responsible for maintaining only one instance of class(Breaks Single Responsibility).
3.They make the System Tightly Coupled.
Implementation:
1.Non-Thread Safe
2.Thread Safe-Single Lock
3.Thread Safe -Double Check Lock
4.Thread Safe-Lazy Loading.
Source Code:
#43:Deploying Application to GAC
To Deploy Assembly into GAC,It must be strongly named Assembly.
To Add assembly,you can use GACUTIL.exe.A utility Microsoft ships to manage GAC.
To install :
gacutil.exe -i yourapp.dll
To Remove:
gacutil.exe -u yourapp.dll
You can locate the installed assembly at (C:\\Windows\Microsoft.NET\GAC_UTIL)


