serving the solutions day and night

Pages

Showing posts with label extension methods. Show all posts
Showing posts with label extension methods. Show all posts

Saturday, April 3, 2010

Extension Methods, DataSet & DataReader

Extension methods help you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type. Extension methods are a special kind of static method.

For example, let us assume Car.dll is the 3rd party DLL and source is not available.
Car Class Library - Details.CS
namespace Car
{
    public class Details
    {
        public string Wheel(string cartype)
        {
            if (cartype=="CORROLA")
                return "Two";
            if (cartype == "JEEP")
                return "Four";
            else
                return "No Wheel";
        }
    }
}