Click here to Skip to main content
15,887,683 members
Home / Discussions / C#
   

C#

 
QuestionGoogle Maps Pin
JohnUSA10-Jun-10 2:53
JohnUSA10-Jun-10 2:53 
AnswerMessage Closed Pin
10-Jun-10 3:06
stancrm10-Jun-10 3:06 
GeneralRe: Google Maps Pin
JohnUSA10-Jun-10 4:45
JohnUSA10-Jun-10 4:45 
AnswerRe: Google Maps Pin
Paladin200010-Jun-10 4:41
Paladin200010-Jun-10 4:41 
GeneralRe: Google Maps Pin
JohnUSA10-Jun-10 4:53
JohnUSA10-Jun-10 4:53 
GeneralRe: Google Maps Pin
Paladin200010-Jun-10 5:20
Paladin200010-Jun-10 5:20 
AnswerRe: Google Maps Pin
Adam R Harris10-Jun-10 4:52
Adam R Harris10-Jun-10 4:52 
QuestionTricky Inheritance Question Pin
Jon Myers10-Jun-10 2:47
Jon Myers10-Jun-10 2:47 
OK, this program is from a class I'm taking, it's an example out of our book. You have four classes, D inherits from C, C from B and B from A. I kind of understand how this works but I'm not sure.

Question. Is this considered a single object? Only one object is created but do the references make the other classes(or the methods within them) part of the same object?

I think I understand the rest.
1.) D is called and outputs 'D' becuase that is the method within D.
2.) Since C is virtual and it's child class D overries it, C also outputs 'D'.
3.) Since C is declared 'new' that hides C from B (I assume it also hides D from B) and therefore B outputs it own method and displays 'B'
4.) A is virtual and since its child class B overrides it, it also outputs 'B'.

Sorry, but I think my brain actually froze for a while when I was trying to figure this out and I'm just trying to see if anyone has any input or knows if I'm right.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Example
{
    class A
    {
        public virtual void M() { Console.WriteLine("A"); }
    }

    class B : A
    {
        public override void M() { Console.WriteLine("B");  }
    }

    class C : B
    {
        new public virtual void M() { Console.WriteLine("C"); }
    }

    class D : C
    {
        public override void M() { Console.WriteLine("D"); }
    }

    class Program
    {
        static void Main(string[] args)
        {
            D d = new D();
            C c = d;
            B b = c;
            A a = b;

            d.M();
            c.M();
            b.M();
            a.M();
        }
    }
}

AnswerRe: Tricky Inheritance Question Pin
Andrew Rissing10-Jun-10 4:21
Andrew Rissing10-Jun-10 4:21 
GeneralRe: Tricky Inheritance Question Pin
Jon Myers10-Jun-10 5:40
Jon Myers10-Jun-10 5:40 
GeneralRe: Tricky Inheritance Question Pin
Andrew Rissing10-Jun-10 7:34
Andrew Rissing10-Jun-10 7:34 
QuestionAuto serial software Pin
ostad_mrn10-Jun-10 2:39
ostad_mrn10-Jun-10 2:39 
AnswerRe: Auto serial software Pin
#realJSOP10-Jun-10 2:49
mve#realJSOP10-Jun-10 2:49 
QuestionRe: Auto serial software Pin
ostad_mrn10-Jun-10 3:13
ostad_mrn10-Jun-10 3:13 
AnswerRe: Auto serial software Pin
#realJSOP10-Jun-10 4:26
mve#realJSOP10-Jun-10 4:26 
QuestionHow to find duplicate values in two or more Excel files? Pin
bebef_198710-Jun-10 2:27
bebef_198710-Jun-10 2:27 
AnswerRe: How to find duplicate values in two or more Excel files? Pin
Adam R Harris10-Jun-10 4:58
Adam R Harris10-Jun-10 4:58 
QuestionCan I pass binary data of a file to WebBrowser control? Pin
Ahmad Safwat10-Jun-10 1:32
Ahmad Safwat10-Jun-10 1:32 
AnswerRe: Can I pass binary data of a file to WebBrowser control? Pin
Luc Pattyn10-Jun-10 1:51
sitebuilderLuc Pattyn10-Jun-10 1:51 
GeneralRe: Can I pass binary data of a file to WebBrowser control? Pin
Ahmad Safwat10-Jun-10 1:56
Ahmad Safwat10-Jun-10 1:56 
AnswerRe: Can I pass binary data of a file to WebBrowser control? Pin
Giorgi Dalakishvili10-Jun-10 2:14
mentorGiorgi Dalakishvili10-Jun-10 2:14 
GeneralRe: Can I pass binary data of a file to WebBrowser control? Pin
Ahmad Safwat10-Jun-10 2:45
Ahmad Safwat10-Jun-10 2:45 
GeneralRe: Can I pass binary data of a file to WebBrowser control? Pin
Luc Pattyn10-Jun-10 3:44
sitebuilderLuc Pattyn10-Jun-10 3:44 
GeneralRe: Can I pass binary data of a file to WebBrowser control? Pin
Ahmad Safwat10-Jun-10 4:14
Ahmad Safwat10-Jun-10 4:14 
GeneralRe: Can I pass binary data of a file to WebBrowser control? Pin
Luc Pattyn10-Jun-10 4:28
sitebuilderLuc Pattyn10-Jun-10 4:28 

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.