Click here to Skip to main content
12,697,779 members (25,861 online)
   

C#

 
AnswerRe: How to write c# version of Delphi's Abort procedure Pin
Richard MacCutchan30-Jan-13 23:07
mvpRichard MacCutchan30-Jan-13 23:07 
AnswerRe: How to write c# version of Delphi's Abort procedure Pin
Shameel31-Jan-13 1:18
memberShameel31-Jan-13 1:18 
AnswerRe: How to write c# version of Delphi's Abort procedure Pin
jschell31-Jan-13 9:21
memberjschell31-Jan-13 9:21 
Question"new" to hide base class implementation - is it useless? Pin
devvvy30-Jan-13 19:17
memberdevvvy30-Jan-13 19:17 
Take a simple example from here[^]

The following example, try remove "new" from B.Yell, it makes no difference (except Compiler will bitch about it).

Let me know if I am mistaken!
class Program
    {
        static void Main(string[] args)
        {
            try
            {
                A ref1 = new A(); 
                A ref2 = new B();
                B ref3 = new B();

                ref1.Y(); <-- A.Yell
                ref2.Y(); <-- B.Yell
                ref3.Y(); <-- Always B.Yell, regardless whether you decorated Yell() with "new" or not! (This makes the keyword useless)
            }
            catch (Exception Ex)
            {
                Console.WriteLine("Main.Exception - " + Ex.ToString());
            }

            return;
        }

        class A
        {
            public void Yell()
            {
                Console.WriteLine("A.Yell");
            }
        }

        class B : A
        {
            public new void Yell()
            {
                Console.WriteLine("B.Yell");
            }
        }
    }

dev


modified 31-Jan-13 0:26am.

AnswerRe: "new" to hide base class implementation - is it useless? Pin
Keld Ølykke30-Jan-13 21:03
memberKeld Ølykke30-Jan-13 21:03 
GeneralRe: "new" to hide base class implementation - is it useless? Pin
devvvy30-Jan-13 21:11
memberdevvvy30-Jan-13 21:11 
GeneralRe: "new" to hide base class implementation - is it useless? Pin
Keld Ølykke31-Jan-13 0:45
memberKeld Ølykke31-Jan-13 0:45 
GeneralRe: "new" to hide base class implementation - is it useless? Pin
devvvy31-Jan-13 16:33
memberdevvvy31-Jan-13 16:33 
GeneralRe: "new" to hide base class implementation - is it useless? Pin
Keld Ølykke31-Jan-13 21:56
memberKeld Ølykke31-Jan-13 21:56 
GeneralRe: "new" to hide base class implementation - is it useless? Pin
devvvy1-Feb-13 15:54
memberdevvvy1-Feb-13 15:54 

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.


Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 21 Jan 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid