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

C#

 
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 
N a v a n e e t h wrote:
class Vehicle


Why isn't the class abstract? Smile | :)

Here the "Car" instance is down casted into "Vehicle" instance. Is this performance costly ?


Doesn't cost a thing. The down cast is completely safe, so there is no code generated to handle it.

Or an approach with interfaces like the below one is better ?


You only have a use for the interface if you have a need to make a completely different implementation of the vehicle members for any class. If all vehicles will inherit from the Vehicle class anyway, the interface is superflous.

Despite everything, the person most likely to be fooling you next is yourself.

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 
GeneralRe: App prevents windows to shutdown Pin
GermanDM22-Feb-08 1:31
GermanDM22-Feb-08 1:31 
GeneralPropertyGrid Pin
stancrm21-Feb-08 21:12
stancrm21-Feb-08 21:12 
GeneralRe: PropertyGrid Pin
phannon8621-Feb-08 21:52
professionalphannon8621-Feb-08 21:52 
GeneralRe: PropertyGrid Pin
stancrm21-Feb-08 22:05
stancrm21-Feb-08 22:05 
GeneralRe: PropertyGrid Pin
phannon8621-Feb-08 22:19
professionalphannon8621-Feb-08 22:19 
GeneralRe: PropertyGrid Pin
Pete O'Hanlon21-Feb-08 22:51
mvePete O'Hanlon21-Feb-08 22:51 
GeneralRe: PropertyGrid Pin
visualhint27-Feb-08 15:05
visualhint27-Feb-08 15:05 
GeneralListView item Pin
Maddie from Dartford21-Feb-08 20:57
Maddie from Dartford21-Feb-08 20:57 

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.