C# can an inherited method or property use the derived class members without creating a new method?
===

I'm coding a simple game using C# to help me learn basic object oriented concepts.

In this code below:

    class entity
        {
        int hp;
        string name;

        public entity()
        {
            hp = 1;
            name = "entity";
        }

        public string status()
        {
            string result;
            result=name + "#" + " HP:" + hp;
            return result;
        }






        class dragon : entity
        {

        new public string name;
        new int hp;


        public dragon()
        {
            hp = 100;
            name = "Dragon";
            
        }
    }

I made an object for "Dragon" as such

    dragon mydragon = new dragon();

The problem is with the following code:

    mydragon.status();

This returns a string but with the "name" and "hp" of the **entity** class object (i.e. hp=1, name=entity).

I'd like to have this return the dragon object's values (hp=100, name=dragon). I'm not sure what I'm doing wrong but it seems dead simple.

After fiddling and struggling for hours, the only solution I could come to was to simply copy & paste the **status()** method over to the dragon class. But I'm sure there's a better way to do this.

Many thanks in advance.


