S
Steven Quail
Hi to all,
Having come from a delphi environment, I remember that when using
interfaces, we were told not to mix the object models and interface
models. In other words, when I create an object, return and interface
straight away, instead of creating an object of type object and then
getting the interface. The reason given for this was that when passing
interfaces around, the interface could
release the object and then if I try to use the object reference, I
would
get access violations.
In C# I have seen examples like:
Person myPerson;
AddressInterface IAddress;
myPerson = Person.Create;
AddressInterface = myPerson as IAddress;
etc.
Is this correct or should I do :
AddressInterface = Person.Create;
In which case I never ever use myPerson.
TIA
Steven.
Having come from a delphi environment, I remember that when using
interfaces, we were told not to mix the object models and interface
models. In other words, when I create an object, return and interface
straight away, instead of creating an object of type object and then
getting the interface. The reason given for this was that when passing
interfaces around, the interface could
release the object and then if I try to use the object reference, I
would
get access violations.
In C# I have seen examples like:
Person myPerson;
AddressInterface IAddress;
myPerson = Person.Create;
AddressInterface = myPerson as IAddress;
etc.
Is this correct or should I do :
AddressInterface = Person.Create;
In which case I never ever use myPerson.
TIA
Steven.