sachin dimbre

sachin dimbre

  • NA
  • 15
  • 18.9k

child class is not inheriting property from parent

Nov 1 2013 7:31 AM

Hello,

I have a class something like below.

namespace Tool
{   
    public class uielement : parentuielement
    {
        protected uielement();
        public uielement(Element element);
  
        public static implicit operator uielement(Element element);
        public static implicit operator uielement(string path);
  
        public uielement NextGeneration { get; }  
 }
}

For this class above I have created child as below.

namespace myobject
{
    public class Wuielement : Tool.uielement
    {
        public Wuielement()
            : base()
        {
        }

        public Wuielement(Element element)
            : base(element)
        {
        }

        public static implicit operator Wuielement(string path)
        {
            return new Wuielement(path);
        }

        public static implicit operator Wuielement(Ranorex.Core.Element element)
        {
            return new Wuielement(element);
        }
    }
}

Now when I am using this
Ex. myobject.Wuielement edit = ele.As<myobject.Wuielement>().NextGeneration;
Here this gives error something like "Cannot Implicitly conver type 'Tool.uielement' to 'myobject.Wuielement'".
Look like the property .NextGeneration is returning parent type (Tool.uielement) whereas it should return 'myobject.Wuielement'

What is the problem here? Why not child 'myobject.Wuielement' has inherited property '.NextGeneration'?


Thanks in advance...

Sachin


Answers (3)