Click here to Skip to main content
15,891,943 members
Home / Discussions / C#
   

C#

 
GeneralRe: Problem related to grid Pin
lalit1424-Sep-09 19:54
lalit1424-Sep-09 19:54 
GeneralRe: Problem related to grid Pin
OriginalGriff25-Sep-09 0:07
mveOriginalGriff25-Sep-09 0:07 
AnswerRe: Problem related to grid Pin
Vimalsoft(Pty) Ltd23-Sep-09 22:23
professionalVimalsoft(Pty) Ltd23-Sep-09 22:23 
Questioni need some help Pin
Mohamed El-Wehishy23-Sep-09 20:20
Mohamed El-Wehishy23-Sep-09 20:20 
AnswerRe: i need some help Pin
N a v a n e e t h23-Sep-09 20:42
N a v a n e e t h23-Sep-09 20:42 
AnswerRe: i need some help Pin
Mohamed El-Wehishy23-Sep-09 20:54
Mohamed El-Wehishy23-Sep-09 20:54 
GeneralRe: i need some help [modified] Pin
N a v a n e e t h23-Sep-09 21:10
N a v a n e e t h23-Sep-09 21:10 
QuestionWindows media Control Pin
jpk42023-Sep-09 20:01
jpk42023-Sep-09 20:01 
AnswerRe: Windows media Control Pin
N a v a n e e t h23-Sep-09 20:55
N a v a n e e t h23-Sep-09 20:55 
GeneralRe: Windows media Control Pin
jpk42023-Sep-09 23:37
jpk42023-Sep-09 23:37 
GeneralRe: Windows media Control Pin
N a v a n e e t h24-Sep-09 0:11
N a v a n e e t h24-Sep-09 0:11 
Questionerror "Object reference not set to an instance of an object" pls see the code and help me Pin
amaankhan23-Sep-09 19:58
amaankhan23-Sep-09 19:58 
AnswerRe: error "Object reference not set to an instance of an object" pls see the code and help me Pin
PIEBALDconsult23-Sep-09 20:02
mvePIEBALDconsult23-Sep-09 20:02 
GeneralRe: error "Object reference not set to an instance of an object" pls see the code and help me Pin
amaankhan23-Sep-09 20:06
amaankhan23-Sep-09 20:06 
AnswerRe: error "Object reference not set to an instance of an object" pls see the code and help me Pin
N a v a n e e t h23-Sep-09 20:08
N a v a n e e t h23-Sep-09 20:08 
QuestionInsert values into a table only if they do not already exist in that table (MS Access) Pin
Ajithevn23-Sep-09 19:55
Ajithevn23-Sep-09 19:55 
AnswerRe: Insert values into a table only if they do not already exist in that table (MS Access) [modified] Pin
PIEBALDconsult23-Sep-09 20:13
mvePIEBALDconsult23-Sep-09 20:13 
GeneralRe: Insert values into a table only if they do not already exist in that table (MS Access) Pin
Ajithevn23-Sep-09 20:20
Ajithevn23-Sep-09 20:20 
GeneralRe: Insert values into a table only if they do not already exist in that table (MS Access) Pin
PIEBALDconsult23-Sep-09 20:32
mvePIEBALDconsult23-Sep-09 20:32 
QuestionInterface type or class type? Pin
shivapriyak23-Sep-09 19:30
shivapriyak23-Sep-09 19:30 
AnswerRe: Interface type or class type? Pin
PIEBALDconsult23-Sep-09 19:46
mvePIEBALDconsult23-Sep-09 19:46 
GeneralRe: Interface type or class type? Pin
shivapriyak23-Sep-09 19:48
shivapriyak23-Sep-09 19:48 
GeneralRe: Interface type or class type? Pin
PIEBALDconsult23-Sep-09 19:58
mvePIEBALDconsult23-Sep-09 19:58 
GeneralRe: Interface type or class type? Pin
shivapriyak23-Sep-09 20:54
shivapriyak23-Sep-09 20:54 
GeneralRe: Interface type or class type? Pin
N a v a n e e t h23-Sep-09 23:19
N a v a n e e t h23-Sep-09 23:19 
Consider the following example for using interface as parameter
class Driver
{
    IVehicle vehicleToDrive = null;
 
    Driver(IVehicle vehicleToDrive){
        this.vehicleToDrive = vehicleToDrive;
    }

    public void StartDriving() {
        vehicleToDrive.Start();
        vehicleToDrive.ChangeGear();
        vehicleToDrive.Accelerate();
    }
}
In the above example, you are programming against an interface. The driver is generic and can drive any vehicle that implements IVehicle. In such situations interfaces are useful.

Following example shows how it is helpful in return types.
IVehicle vehicle = VehicleRepository.Create("Benz"); // you get a benz here which implements IVehicle

class VehicleRepository
{
    public static IVehicle Create(string vehicleName)
    {
        IVehicle vehicle = null;
        if(vehicleName == "Benz")
            vehicle = new Benz();
        else if(vehicleName == "Ford")
            vehicle = new Ford(); 
        return vehicle;
    }
}
VehicleRepository.Create method can implement any concrete type of vehicles without changing the return type.

Here is an example when it is used as field.
class BusinessValidation
{
    IValidator[] validators = { 
            new NameValidator(), 
            new AgeValidator(), 
            new DesignationValidator() };

    void Validate()
    {
        foreach(IValidator validator in validators){
          validator.PerformValidation();
        }   
    }
}
Hope it is clear now.


General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.