incubator-etch-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michal Miksovic (JIRA)" <>
Subject [jira] [Created] (ETCH-168) @ToString and inheritance
Date Thu, 18 Aug 2011 02:59:27 GMT
@ToString and inheritance

                 Key: ETCH-168
             Project: Etch
          Issue Type: Improvement
          Components: csharp-binding
    Affects Versions: 1.1
            Reporter: Michal Miksovic
            Priority: Minor

In inheritance tree of exceptions each exception has its GetMessage() method marked as 'new'
which disables user from using polymorphism when having ancestor instance of ancestor exception
cast to base type. Wouldn't it be better to use virtual GetMessage method on the base class
and then have it overridden in ancestors?


public class BaseException
	public virtual string GetMessage() { return "Base exception message";}
	//public string GetMessage(){...}

public class InheritedException : BaseException
	public override string GetMessage() { return "Inhertied exception message";}
	//currently hiding the method from base class
	//public new string GetMessage(){...}

so then

((new InheritedException())as BaseException).GetMessage(); //would return "Inherited exception

This message is automatically generated by JIRA.
For more information on JIRA, see:


View raw message