.Net Example: Virtual Members

In ATEasy DotNet example, the classes DotNetClass1, DotNetClass2, and DotNetClass3 are declared as such:

DotNetClass2 is derived from DotNetClass1
DotNetClass3 is derived from DotNetClass2

And all have a virtual property and a virtual method called:

VirtualProp()

VirtualMethod()

Notice that the flag 'Virtual' was checked in the property pages:

 

The following example shows that you can make the following assignment because cls1 and cls2 does belong to cls3:

cls3=new DotNetClass3()

cls2=cls3

cls1=cls3

Because VirtualProp() and VirtualMethod() are virtual, each call with different class evokes the same function:

! virtual props

s=cls3.VirtualProp()

if (s<>"DotNetClass3.VirtualProp" OR cls1.VirtualProp()<>s OR cls2.VirtualProp()<>s)

TestStatus=Fail

endif

! virtual methods

s=cls3.VirtualMethod()

if (s<>"DotNetClass3.VirtualMethod" OR cls1.VirtualMethod()<>s OR cls2.VirtualMethod()<>s)

TestStatus=Fail

endif