Click here to Skip to main content
15,911,762 members
Home / Discussions / C#
   

C#

 
GeneralRe: problem in file deletion Pin
Xmen Real 22-Feb-08 2:47
professional Xmen Real 22-Feb-08 2:47 
GeneralRe: problem in file deletion Pin
Luc Pattyn22-Feb-08 2:04
sitebuilderLuc Pattyn22-Feb-08 2:04 
GeneralRe: problem in file deletion Pin
Ravenet22-Feb-08 3:11
Ravenet22-Feb-08 3:11 
GeneralProblem with tabindex settings Pin
Dev Motiramani21-Feb-08 23:24
Dev Motiramani21-Feb-08 23:24 
GeneralRe: Problem with tabindex settings Pin
phannon8621-Feb-08 23:27
professionalphannon8621-Feb-08 23:27 
GeneralRe: Problem with tabindex settings Pin
Dev Motiramani22-Feb-08 0:02
Dev Motiramani22-Feb-08 0:02 
GeneralRe: Problem with tabindex settings Pin
phannon8622-Feb-08 0:13
professionalphannon8622-Feb-08 0:13 
GeneralDowncasting VS Interfaces - Performance perceptive Pin
N a v a n e e t h21-Feb-08 23:02
N a v a n e e t h21-Feb-08 23:02 
Assume I have two classes like this.
class Vehicle
{
    public string Name
    { 
        get { return name;} 
    }
}

class Bike : Vehicle
{
}

class Car : Vehicle
{
}
I have a factory class like
class VehicleFactory
{
    public static Vehicle CreateVehicle()
    {
         return new Car();
    }
}
Here the "Car" instance is down casted into "Vehicle" instance. Is this performance costly ? Or an approach with interfaces like the below one is better ?
interface IVehicle
{
    void Name
    {
       get;
    }
}

class Vehicle
{
    public string Name{ get { return name;} }
}

class Bike : Vehicle , IVehicle
{
}

class Car : Vehicle , IVehicle
{
}
and the factory returns IVehicle instance.
class VehicleFactory
{
    public static IVehicle CreateVehicle()
    {
         return new Car() as IVehicle;
    }
}
Which one do you suggest ?

All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia

My Website | Ask smart questions

GeneralRe: Downcasting VS Interfaces - Performance perceptive Pin
Colin Angus Mackay21-Feb-08 23:39
Colin Angus Mackay21-Feb-08 23:39 
GeneralRe: Downcasting VS Interfaces - Performance perceptive Pin
N a v a n e e t h22-Feb-08 3:21
N a v a n e e t h22-Feb-08 3:21 
GeneralRe: Downcasting VS Interfaces - Performance perceptive Pin
Roger Alsing21-Feb-08 23:44
Roger Alsing21-Feb-08 23:44 
GeneralRe: Downcasting VS Interfaces - Performance perceptive Pin
N a v a n e e t h22-Feb-08 3:20
N a v a n e e t h22-Feb-08 3:20 
GeneralRe: Downcasting VS Interfaces - Performance perceptive Pin
Pete O'Hanlon21-Feb-08 23:57
mvePete O'Hanlon21-Feb-08 23:57 
GeneralRe: Downcasting VS Interfaces - Performance perceptive Pin
N a v a n e e t h22-Feb-08 3:18
N a v a n e e t h22-Feb-08 3:18 
GeneralRe: Downcasting VS Interfaces - Performance perceptive Pin
Pete O'Hanlon22-Feb-08 4:28
mvePete O'Hanlon22-Feb-08 4:28 
GeneralRe: Downcasting VS Interfaces - Performance perceptive Pin
Guffa22-Feb-08 0:28
Guffa22-Feb-08 0:28 
GeneralRe: Downcasting VS Interfaces - Performance perceptive Pin
N a v a n e e t h22-Feb-08 3:17
N a v a n e e t h22-Feb-08 3:17 
GeneralRe: Downcasting VS Interfaces - Performance perceptive Pin
Mike Dimmick22-Feb-08 1:37
Mike Dimmick22-Feb-08 1:37 
GeneralRe: Downcasting VS Interfaces - Performance perceptive Pin
N a v a n e e t h22-Feb-08 3:16
N a v a n e e t h22-Feb-08 3:16 
GeneralDatagridview, checkbox and text in same cell Pin
akkram21-Feb-08 22:27
akkram21-Feb-08 22:27 
GeneralRe: Datagridview, checkbox and text in same cell Pin
Ravenet22-Feb-08 3:17
Ravenet22-Feb-08 3:17 
GeneralApp prevents windows to shutdown Pin
GermanDM21-Feb-08 22:00
GermanDM21-Feb-08 22:00 
GeneralRe: App prevents windows to shutdown Pin
Xmen Real 22-Feb-08 1:16
professional Xmen Real 22-Feb-08 1:16 
GeneralRe: App prevents windows to shutdown Pin
GermanDM22-Feb-08 1:22
GermanDM22-Feb-08 1:22 
GeneralRe: App prevents windows to shutdown Pin
Xmen Real 22-Feb-08 1:27
professional Xmen Real 22-Feb-08 1:27 

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.