Click here to Skip to main content
15,919,434 members
Home / Discussions / C#
   

C#

 
AnswerRe: how can i do this ? Pin
Guffa7-Jan-08 3:01
Guffa7-Jan-08 3:01 
GeneralRe: how can i do this ? Pin
Stu Richardson7-Jan-08 3:46
Stu Richardson7-Jan-08 3:46 
GeneralRe: how can i do this ? Pin
prasadbuddhika7-Jan-08 20:10
prasadbuddhika7-Jan-08 20:10 
GeneralRe: how can i do this ? Pin
Stu Richardson7-Jan-08 22:12
Stu Richardson7-Jan-08 22:12 
Questiondoes c# have these features built in ? Pin
prasadbuddhika7-Jan-08 0:53
prasadbuddhika7-Jan-08 0:53 
AnswerRe: does c# have these features built in ? Pin
Pete O'Hanlon7-Jan-08 0:57
mvePete O'Hanlon7-Jan-08 0:57 
AnswerRe: does c# have these features built in ? Pin
Scott Dorman7-Jan-08 14:51
professionalScott Dorman7-Jan-08 14:51 
GeneralPolymorphism and inheritance Pin
Goncalo Oliveira7-Jan-08 0:34
Goncalo Oliveira7-Jan-08 0:34 
Let's see if I can explain my small doubt. I can go around this, but as I was coding something, I got curious if something wasn't possible to do in c#.

In C++, you could have something like this:

<br />
class A<br />
{<br />
   public virtual void method()<br />
   {<br />
      // something<br />
   }<br />
}<br />
<br />
class AA : public A<br />
{<br />
   public void method()<br />
   {<br />
      // something else<br />
   }<br />
}<br />
<br />
class AB : public B<br />
{<br />
   public void method()<br />
   {<br />
      // even something else<br />
   }<br />
}<br />
<br />
A *obj;<br />
<br />
if ( something )<br />
{<br />
   obj = (A)( new AA() );<br />
}<br />
else<br />
{<br />
   obj = (A)( new AB() );<br />
}<br />
<br />
obj->method();<br />
<br />


What happens here is that when you invoke the method function, you'll be executing the implementation from AA or from AB and not from A. Though, in C#, if I try to do something like this, you'll be executing the implementation from A. That fact to me, is a shame... I liked this behavior. And as pointers in C# only exist for values, I suppose this is not possible with C#.

Best regards

Gonçalo A.

GeneralRe: Polymorphism and inheritance Pin
originSH7-Jan-08 1:42
originSH7-Jan-08 1:42 
GeneralRe: Polymorphism and inheritance Pin
Goncalo Oliveira7-Jan-08 1:50
Goncalo Oliveira7-Jan-08 1:50 
GeneralRe: Polymorphism and inheritance Pin
originSH7-Jan-08 2:04
originSH7-Jan-08 2:04 
GeneralRe: Polymorphism and inheritance Pin
Goncalo Oliveira7-Jan-08 2:55
Goncalo Oliveira7-Jan-08 2:55 
GeneralRe: Polymorphism and inheritance Pin
Luc Pattyn7-Jan-08 3:59
sitebuilderLuc Pattyn7-Jan-08 3:59 
GeneralRe: Polymorphism and inheritance Pin
Goncalo Oliveira7-Jan-08 4:09
Goncalo Oliveira7-Jan-08 4:09 
Generaloledb provider for odbc drivers error Pin
Naresh1234567897-Jan-08 0:29
Naresh1234567897-Jan-08 0:29 
GeneralRe: oledb provider for odbc drivers error Pin
PIEBALDconsult7-Jan-08 6:20
mvePIEBALDconsult7-Jan-08 6:20 
Generalprogress bar Pin
Naresh1234567897-Jan-08 0:20
Naresh1234567897-Jan-08 0:20 
GeneralRe: progress bar Pin
Rocky#7-Jan-08 1:11
Rocky#7-Jan-08 1:11 
GeneralRe: progress bar Pin
Patrick Etc.7-Jan-08 4:52
Patrick Etc.7-Jan-08 4:52 
GeneralToolBox Pin
topksharma19827-Jan-08 0:17
topksharma19827-Jan-08 0:17 
GeneralRe: ToolBox Pin
Rocky#7-Jan-08 1:13
Rocky#7-Jan-08 1:13 
QuestionProgress bar problem Pin
Naresh1234567896-Jan-08 23:52
Naresh1234567896-Jan-08 23:52 
GeneralHI Pin
Naresh1234567896-Jan-08 23:45
Naresh1234567896-Jan-08 23:45 
GeneralRe: HI Pin
Mircea Puiu6-Jan-08 23:51
Mircea Puiu6-Jan-08 23:51 
GeneralRe: HI Pin
Naresh1234567897-Jan-08 0:14
Naresh1234567897-Jan-08 0:14 

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.