Hello!
My question is about calling this method CollectData below but I get a
compile error that I shouldn't have because the type parameter is correct.
The compile error is the following:
C:\PK\Development\Products\UTCAS\4.0\SRC\MeltPracA pplication\Dialog\Composit
ionForm.cs(942): Argument '1': cannot convert from 'ref
MeltPracData.MeltPracDataComposition' to 'ref
MeltPracCommon.IDialogPostData'
public bool CollectData(ref IDialogPostData post)
{...}
This IDialogPostData is an interface of type
MeltPracCommon.IDialogPostData.
We have an abstract class called MeltPracData which has the following
definition
public abstract class MeltPracData : IDialogPostData
{...}
As you can see this MeltPracData implements IDialogPostData
I have another class called MeltPracDataComposition which has the following
definition.
public class MeltPracDataComposition : MeltPracData
{...}
As you can see this MeltPracDataComposition is an MeltPracData according to
general inheritance rules.
In my program I have these two statement
MeltPracDataComposition mpd = new MeltPracDataComposition();
CollectData(ref mpd);
which cause compile error.
In my opinion these two statements shouldn't cause any compile error.
Some comment why these two statements shouldn't cause any compile error.
First of all I instansiate an MeltPracDataComposition which is an
MeltPracData
and a MeltPracData implement IDialogPostData.
This mean that I can send an actual parameter of type
MeltPracDataComposition
and receive it as an formal parameter of type IDialogPostData.
Another strange thing is if a remove the ref in the CollectData and
call it in this way CollectData(mpd);
I don't get any compile error.
I know what ref means but I can't figure out why I get a compile error when
having this ref in the method definition for collectData.
//Tony