Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Generics as Properties & Parameters
Message
De
12/05/2007 18:08:43
Jeff Corder
Ambit Technologies, LLC
Missouri, États-Unis
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Generics as Properties & Parameters
Divers
Thread ID:
01225008
Message ID:
01225008
Vues:
72
I just upgraded to 2.4 and followed the steps in the Upgrading guide. All went well in the business objects. Then I started compiling my projects to see what needs changed.

I have several routines where I am passing business objects or I have a public property that is a business object. I'm having a hard time figuring out how to handle this with the generics.

One example: I have a constructor:
public DataDup(ABusinessObject bizObj, CopyType copyType,bool primaryBizObj, string foreignKey)

That was working fine. After adding the generics, the I got a compiler error and change the first parameter to ABusinessObject made the compiler happy. Unfortunately, I can't seem to fix the error in the calling routine. The compiler complains that it can't convert the specific business object (AddressesShipping) to the generic (ABusinessObject.

I can change the first parameter to an object, then cast it to ABusinessObject when I use or store it, but that does not seem like a very safe solution.

I guess the question boils down to: How do I pass the new business object to a method?

Thanks,
Jeff
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform