Click here to Skip to main content
15,909,896 members
Home / Discussions / C#
   

C#

 
GeneralRe: MS-DOS Command Pin
Paul Conrad18-Jan-08 18:01
professionalPaul Conrad18-Jan-08 18:01 
QuestionHow to call a base class method? Pin
Miszou18-Jan-08 13:58
Miszou18-Jan-08 13:58 
AnswerRe: How to call a base class method? Pin
Ed.Poore18-Jan-08 14:56
Ed.Poore18-Jan-08 14:56 
AnswerRe: How to call a base class method? [modified] Pin
PIEBALDconsult18-Jan-08 14:58
mvePIEBALDconsult18-Jan-08 14:58 
GeneralRe: How to call a base class method? Pin
Colin Angus Mackay18-Jan-08 15:05
Colin Angus Mackay18-Jan-08 15:05 
GeneralRe: How to call a base class method? Pin
PIEBALDconsult18-Jan-08 15:19
mvePIEBALDconsult18-Jan-08 15:19 
GeneralRe: How to call a base class method? Pin
Miszou18-Jan-08 16:38
Miszou18-Jan-08 16:38 
GeneralA problem with casting Pin
Clive D. Pottinger18-Jan-08 13:27
Clive D. Pottinger18-Jan-08 13:27 
Hello everyone.

I'm back, and that means... yes, in my ongoing attempts to self-learn C# and .NET, I have once again painted (or coded) myself into a corner.

I managed to write a bunch of code and now find that it needs to be able to do an invalid casting in order for me to proceed. Basically, I have created a class (let's say "Automobile") and other classes ("Truck" and "Van") that are derived from it.

Unfortunately I find my self in the situation where I created
Automobile rentedCar = new Automobile();
but now I need to use rentedCar as a Van. However
Van myWheels = (Van)rentedCar;
is illegal.

I have to create rentedCar first [so that I can rentedCar.DriveHome()], but I do not know ahead of time whether I will be trying to use rentedCar as a Van or a Truck - depends on whether the kids have a soccer game [myWheels.PlayDisneyDVD()] or if a friend is moving [myWheels.DropTailgate()] Smile | :) .


Could someone point me in the right direction for solving this please? Is this what generics are for?

I know, in your world you determine the type of vehicle you want and then rent it. But in my world, we rent it first, drive it home and then decide what kind of vehicle we want it to be - and we like it that way! Laugh | :laugh:

Clive Pottinger
Victoria, BC

GeneralRe: A problem with casting Pin
Ed.Poore18-Jan-08 13:57
Ed.Poore18-Jan-08 13:57 
GeneralRe: A problem with casting Pin
Luc Pattyn18-Jan-08 14:14
sitebuilderLuc Pattyn18-Jan-08 14:14 
GeneralRe: A problem with casting Pin
J$18-Jan-08 14:18
J$18-Jan-08 14:18 
GeneralRe: A problem with casting Pin
PIEBALDconsult18-Jan-08 15:33
mvePIEBALDconsult18-Jan-08 15:33 
GeneralRe: A problem with casting Pin
Clive D. Pottinger19-Jan-08 5:05
Clive D. Pottinger19-Jan-08 5:05 
GeneralProblem wyth colors (uint, hexa) Pin
alayle18-Jan-08 12:37
alayle18-Jan-08 12:37 
GeneralRe: Problem wyth colors (uint, hexa) Pin
Luc Pattyn18-Jan-08 13:09
sitebuilderLuc Pattyn18-Jan-08 13:09 
QuestionADO.net: How to omit Columns from a DataTable in a DataGridView??? Pin
dergunnar18-Jan-08 10:14
dergunnar18-Jan-08 10:14 
AnswerRe: ADO.net: How to omit Columns from a DataTable in a DataGridView??? Pin
Gareth H18-Jan-08 10:27
Gareth H18-Jan-08 10:27 
AnswerRe: ADO.net: How to omit Columns from a DataTable in a DataGridView??? Pin
ChrisKo18-Jan-08 11:04
ChrisKo18-Jan-08 11:04 
AnswerRe: ADO.net: How to omit Columns from a DataTable in a DataGridView??? Pin
dergunnar18-Jan-08 12:44
dergunnar18-Jan-08 12:44 
GeneralDrawing Circle and picture in that Pin
alishazdeh18-Jan-08 9:48
alishazdeh18-Jan-08 9:48 
GeneralRe: Drawing Circle and picture in that Pin
Ennis Ray Lynch, Jr.18-Jan-08 9:54
Ennis Ray Lynch, Jr.18-Jan-08 9:54 
GeneralDataSet Pin
simworld18-Jan-08 9:44
simworld18-Jan-08 9:44 
GeneralRe: DataSet Pin
PIEBALDconsult18-Jan-08 9:49
mvePIEBALDconsult18-Jan-08 9:49 
GeneralRe: DataSet Pin
simworld19-Jan-08 8:26
simworld19-Jan-08 8:26 
GeneralPrint Preview in landscape Pin
Christian Graus18-Jan-08 9:21
protectorChristian Graus18-Jan-08 9:21 

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.