Throw Vs Throw ex Posted: 29 Jun 2010 08:41 AM PDT Throw Throw Ex try { // do some operation that can fail } catch (Exception ex) { // do some local cleanup throw ; } try { // do some operation that can fail } catch (Exception ex) { // do some local cleanup throw ex; } It preserve the Stack information with Exception It Won't Send Stack information with Exception This is called as "Rethrow" This is called as "Breaking the Sta...
There are three basic classifications of patterns Creational, Structural, and Behavioral patterns. Creational Patterns • Abstract Factory :- Creates an instance of several families of classes • Builder : - Separates object construction from its representation • Factory Method :- Creates an instance of several derived classes • Prototype :- A fully initialized instance to be copied or cloned • Singleton :- A class in which only a single instance can exist Note : - The best way to remember Creational pattern is by remembering ABFPS (Abraham Became First President of States). Structural Patterns • Adapter :-Match interfaces of different classes . • Bridge :-Separates an object’s abstraction from its implementation. • Composite :-A tree structure of simple and composite objects. • Decorator :-Add responsibilities to objects dynamically. • Façade :-A single class that represents an entire subsystem. • Flyweight :-A fine-grained instance used for efficient sharing...
As most of you know hiding and overriding are two main features based upon inheritance, which is one of the pillars of the OOP. Using these we can redefine a member of the base class in a derived class. But what are the differences. Let me clear this with a simple example. Start a new web application project with a default web form named "WebForm1" using visual studio. Add 2 class to this project with names "BaseClass" and "DerivedClass". The "DerivedClass" should be a subclass of "BaseClass" (i.e. should define like DerivedClass: BaseClass). Define the following functions in the base class named "BaseClass". Notice the keyword "virtual". public virtual string FunctionToOverride() { return "This is from base class FunctionToOverride"; } public string FunctionToHide() { return "This is ...
Comments
Post a Comment