Click here to Skip to main content
15,904,828 members
Home / Discussions / C#
   

C#

 
GeneralRe: Check it out Pin
Luc Pattyn28-May-09 7:59
sitebuilderLuc Pattyn28-May-09 7:59 
AnswerRe: Many network connections inside threads Pin
led mike28-May-09 7:43
led mike28-May-09 7:43 
GeneralRe: Many network connections inside threads Pin
mohamang30-May-09 7:36
mohamang30-May-09 7:36 
QuestionAforge.net Pin
tibyv28-May-09 4:16
tibyv28-May-09 4:16 
AnswerRe: Aforge.net Pin
Manas Bhardwaj28-May-09 4:17
professionalManas Bhardwaj28-May-09 4:17 
GeneralRe: Aforge.net Pin
Michael Bookatz28-May-09 4:32
Michael Bookatz28-May-09 4:32 
QuestionWindowsService Clarification Pin
MumbleB28-May-09 2:45
MumbleB28-May-09 2:45 
AnswerRe: WindowsService Clarification Pin
PIEBALDconsult28-May-09 3:06
mvePIEBALDconsult28-May-09 3:06 
GeneralRe: WindowsService Clarification Pin
MumbleB28-May-09 3:10
MumbleB28-May-09 3:10 
GeneralRe: WindowsService Clarification Pin
EliottA28-May-09 3:16
EliottA28-May-09 3:16 
GeneralRe: WindowsService Clarification Pin
MumbleB28-May-09 3:31
MumbleB28-May-09 3:31 
AnswerRe: WindowsService Clarification Pin
Calla28-May-09 3:21
Calla28-May-09 3:21 
GeneralRe: WindowsService Clarification Pin
PIEBALDconsult28-May-09 3:36
mvePIEBALDconsult28-May-09 3:36 
QuestionOpen image file with file dialog and use it in the same program run Pin
raouaa28-May-09 2:21
raouaa28-May-09 2:21 
AnswerRe: Open image file with file dialog and use it in the same program run Pin
0x3c028-May-09 2:33
0x3c028-May-09 2:33 
GeneralRe: Open image file with file dialog and use it in the same program run Pin
raouaa29-May-09 2:43
raouaa29-May-09 2:43 
QuestionPeopleSoft_PeopleSoft.tlb Pin
BabuRao.k28-May-09 2:15
BabuRao.k28-May-09 2:15 
AnswerRe: PeopleSoft_PeopleSoft.tlb Pin
Mike Marynowski28-May-09 2:21
professionalMike Marynowski28-May-09 2:21 
AnswerRe: PeopleSoft_PeopleSoft.tlb Pin
Mike Marynowski28-May-09 2:27
professionalMike Marynowski28-May-09 2:27 
QuestionConversion --- need explanation Pin
u060509428-May-09 1:51
u060509428-May-09 1:51 
AnswerRe: Conversion --- need explanation Pin
Rob Philpott28-May-09 2:16
Rob Philpott28-May-09 2:16 
GeneralRe: Conversion --- need explanation Pin
u060509428-May-09 5:54
u060509428-May-09 5:54 
GeneralRe: Conversion --- need explanation Pin
Rob Philpott28-May-09 6:10
Rob Philpott28-May-09 6:10 
Ok, this is all known as polymorphism and is the backbone of object oriented programming.

Firstly, the purpose of a reference type. They didn't exist in languages such as C++, you could create anything either on the heap or the stack, it was your choice. The rules in .NET are a bit more restrictive in that all reference types end up on the heap. It's the concept of maintaining a reference to a thing rather than the thing itself (which absolutely speaking isn't really correct). You can for example have two references to the same object instance. Try that with a value type and you could easily run into problems.

Animal z = new Cat();

Here you have an animal reference to a cat instance. When you call Talk(), whether Animal.Talk() gets called or Cat.Talk() gets called depends on whether that method has been marked as virtual.

If not virtual Animal.Talk() gets called, hopefully for obvious reasons. If the method is virtual however, the runtime will start working through something that used to be called a v-table (don't know what it is in .net) based on the type of the instance not the type of the reference. Cat.Talk() gets called.

This way you can implement Cat.Talk, Dog.Talk, Chicken.Talk, treat any of them as an animal, and call Talk() and it will get resolved to the correct method.

Regards,
Rob Philpott.

GeneralRe: Conversion --- need explanation Pin
OriginalGriff28-May-09 6:19
mveOriginalGriff28-May-09 6:19 
GeneralRe: Conversion --- need explanation Pin
Rob Philpott28-May-09 6:22
Rob Philpott28-May-09 6:22 

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.