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\Developme nt\Products\UTC AS\4.0\SRC\Melt PracApplication \Dialog\Composi t
ionForm.cs(942) : Argument '1': cannot convert from 'ref
MeltPracData.Me ltPracDataCompo sition' 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 MeltPracDataCom position which has the following
definition.
public class MeltPracDataCom position : MeltPracData
{...}
As you can see this MeltPracDataCom position is an MeltPracData according to
general inheritance rules.
In my program I have these two statement
MeltPracDataCom position mpd = new MeltPracDataCom position();
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 MeltPracDataCom position which is an
MeltPracData
and a MeltPracData implement IDialogPostData .
This mean that I can send an actual parameter of type
MeltPracDataCom position
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