Click here to Skip to main content
15,901,426 members
Home / Discussions / C#
   

C#

 
AnswerRe: Inheritence Pin
The Man from U.N.C.L.E.11-Nov-09 22:38
The Man from U.N.C.L.E.11-Nov-09 22:38 
GeneralRe: Inheritence Pin
sris 42611-Nov-09 22:59
sris 42611-Nov-09 22:59 
GeneralRe: Inheritence Pin
dan!sh 11-Nov-09 23:09
professional dan!sh 11-Nov-09 23:09 
GeneralRe: Inheritence Pin
sris 42611-Nov-09 23:14
sris 42611-Nov-09 23:14 
GeneralRe: Inheritence Pin
dan!sh 11-Nov-09 23:23
professional dan!sh 11-Nov-09 23:23 
GeneralRe: Inheritence Pin
The Man from U.N.C.L.E.12-Nov-09 5:05
The Man from U.N.C.L.E.12-Nov-09 5:05 
GeneralRe: Inheritence Pin
sris 42612-Nov-09 5:33
sris 42612-Nov-09 5:33 
GeneralRe: Inheritence Pin
The Man from U.N.C.L.E.12-Nov-09 5:45
The Man from U.N.C.L.E.12-Nov-09 5:45 
As I said, if you mark a method as override sealed in the class in the middle, it then stops classes further down the inheitance tree from overriding that method.

So sealed can be used on a method as shown below.

secondLevelClass cannot override MyMethod when inheriting from subclasstwo, but can if it inherits from subclassone, as you will see from the error if you try to compile the code below.

public class baseclass{
    public virtual void MyMethod(){
    }
}

public class subclassOne : baseclass{
    public override void MyMethod()
    {
        base.MyMethod();
    }
}

public class subclassTwo : baseclass{
    public sealed override void MyMethod()
    {
        base.MyMethod();
    }
}


public class secondlevelClass : subclassTwo{
    public override void MyMethod()
    {
        base.MyMethod();
    }
}


If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk

GeneralRe: Inheritence Pin
PIEBALDconsult12-Nov-09 6:00
mvePIEBALDconsult12-Nov-09 6:00 
GeneralRe: Inheritence Pin
sris 42612-Nov-09 6:08
sris 42612-Nov-09 6:08 
AnswerRe: Inheritence Pin
Eduard Keilholz11-Nov-09 22:45
Eduard Keilholz11-Nov-09 22:45 
GeneralRe: Inheritence Pin
dan!sh 11-Nov-09 22:53
professional dan!sh 11-Nov-09 22:53 
AnswerRe: Inheritence Pin
PIEBALDconsult12-Nov-09 4:11
mvePIEBALDconsult12-Nov-09 4:11 
Questionclick on combobox then display new form Pin
vikas shukla11-Nov-09 21:12
vikas shukla11-Nov-09 21:12 
AnswerRe: click on combobox then display new form Pin
Christian Graus11-Nov-09 21:13
protectorChristian Graus11-Nov-09 21:13 
AnswerRe: click on combobox then display new form Pin
dan!sh 11-Nov-09 21:18
professional dan!sh 11-Nov-09 21:18 
GeneralRe: click on combobox then display new form Pin
Member 59031011-Nov-09 22:54
Member 59031011-Nov-09 22:54 
GeneralRe: click on combobox then display new form Pin
dan!sh 11-Nov-09 23:14
professional dan!sh 11-Nov-09 23:14 
Questionsomeone who can help me!! Pin
miss YY11-Nov-09 21:05
miss YY11-Nov-09 21:05 
AnswerRe: someone who can help me!! Pin
miss YY11-Nov-09 21:07
miss YY11-Nov-09 21:07 
GeneralRe: someone who can help me!! Pin
Christian Graus11-Nov-09 21:10
protectorChristian Graus11-Nov-09 21:10 
GeneralRe: someone who can help me!! Pin
Mycroft Holmes11-Nov-09 21:25
professionalMycroft Holmes11-Nov-09 21:25 
AnswerRe: someone who can help me!! Pin
Christian Graus11-Nov-09 21:09
protectorChristian Graus11-Nov-09 21:09 
AnswerRe: someone who can help me!! Pin
Pete O'Hanlon11-Nov-09 21:33
mvePete O'Hanlon11-Nov-09 21:33 
JokeRe: someone who can help me!! Pin
Christian Graus11-Nov-09 21:36
protectorChristian Graus11-Nov-09 21:36 

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.