Click here to Skip to main content
15,915,094 members
Home / Discussions / C#
   

C#

 
GeneralRe: Update Data Table from Data Source Pin
Wendelius4-Dec-08 4:10
mentorWendelius4-Dec-08 4:10 
QuestionExtracting List Objects Pin
nlowdon3-Dec-08 4:37
nlowdon3-Dec-08 4:37 
AnswerRe: Extracting List Objects Pin
J4amieC3-Dec-08 5:09
J4amieC3-Dec-08 5:09 
AnswerRe: Extracting List Objects [modified] Pin
Thomas Weller3-Dec-08 5:15
Thomas Weller3-Dec-08 5:15 
AnswerRe: Extracting List Objects Pin
moon_stick3-Dec-08 5:20
moon_stick3-Dec-08 5:20 
GeneralRe: Extracting List Objects Pin
J4amieC3-Dec-08 5:29
J4amieC3-Dec-08 5:29 
JokeRe: Extracting List Objects Pin
moon_stick3-Dec-08 5:32
moon_stick3-Dec-08 5:32 
AnswerRe: Extracting List Objects Pin
Guffa3-Dec-08 5:28
Guffa3-Dec-08 5:28 
There are genreally two diffrerent approaches to this, and either might make sense in this case.

1. (As suggested already in the thread) You can create in interface IPettable and make the Cat and Doc implement the interface. Then you can check if the object implements the interface:
foreach (Animal animal in zooAnimals) {
  IPettable pettable = animal as IPettable;
  if (pettable != null) pettable.Pet();
}

2. You can make a common base type for domestic animals:
public abstract class DomesticAnimal : Animal {
   public virtual void Pet();
}

Now you make the Cat and Doc classes inherit DomesticAnimal instead of Animal, and implement the Pet method. You can also implement the Pet method in the DomesticAnimal class if the implementation is the same for Cat and Dog.
foreach (Animal animal in zooAnimals) {
  DomesticAnimal domestic = animal as DomesticAnimal;
  if (domestic != null) domestic.Pet();
}


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

QuestionExpose Objects through Remoting with Windows services Pin
MarkPhB3-Dec-08 2:24
MarkPhB3-Dec-08 2:24 
AnswerRe: Expose Objects through Remoting with Windows services Pin
Jimmanuel3-Dec-08 4:09
Jimmanuel3-Dec-08 4:09 
QuestionHammersley Sampling Pin
GAbirkan3-Dec-08 0:55
GAbirkan3-Dec-08 0:55 
AnswerRe: Hammersley Sampling Pin
Alan Balkany3-Dec-08 4:15
Alan Balkany3-Dec-08 4:15 
QuestionHomography Question Pin
VincentOng2-Dec-08 23:49
VincentOng2-Dec-08 23:49 
AnswerRe: Homography Question Pin
User 66582-Dec-08 23:54
User 66582-Dec-08 23:54 
GeneralRe: Homography Question Pin
VincentOng3-Dec-08 0:00
VincentOng3-Dec-08 0:00 
GeneralRe: Homography Question Pin
User 66583-Dec-08 0:16
User 66583-Dec-08 0:16 
GeneralRe: Homography Question Pin
VincentOng3-Dec-08 0:34
VincentOng3-Dec-08 0:34 
GeneralRe: Homography Question Pin
User 66583-Dec-08 0:56
User 66583-Dec-08 0:56 
GeneralRe: Homography Question Pin
Luc Pattyn3-Dec-08 1:06
sitebuilderLuc Pattyn3-Dec-08 1:06 
GeneralRe: Homography Question Pin
VincentOng3-Dec-08 1:08
VincentOng3-Dec-08 1:08 
GeneralRe: Homography Question Pin
Luc Pattyn3-Dec-08 1:30
sitebuilderLuc Pattyn3-Dec-08 1:30 
GeneralRe: Homography Question Pin
Christian Graus4-Dec-08 8:17
protectorChristian Graus4-Dec-08 8:17 
QuestionConnecting with remote server Pin
SelvaSR2-Dec-08 22:52
SelvaSR2-Dec-08 22:52 
Questionconsole application current path Pin
l.laxmikant2-Dec-08 22:18
l.laxmikant2-Dec-08 22:18 
AnswerRe: console application current path Pin
leppie2-Dec-08 22:37
leppie2-Dec-08 22:37 

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.