Guillaume Slashy
Guillaume Slashy

Reputation: 3624

Override a member inherited?

Here is my class :

public class PrimtivePropertyProxy<T> : FrameworkElement
{
    public string Name
    {
        get;
        private set;
    }
    [....]
}

There already is a field Name in FrameWork element but still, I'd like to define a property name so that when I do :

myPrimtivePropertyProxy.Name;

it returns the Name I defined in my class, and not the one from FrameworkElement. I know this is a complete hiding but, well, that's what I need to do !

Upvotes: 0

Views: 1093

Answers (2)

JiB&#233;Doublev&#233;
JiB&#233;Doublev&#233;

Reputation: 4269

And to avoid the compiler's warning, use the new keyword.

public new string Name
{
    get;
    private set;
}

Upvotes: 0

esskar
esskar

Reputation: 10940

is this what you want?

public new string Name
{
     get;
     private set;
}

Upvotes: 2

Related Questions