Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Generics as Properties & Parameters
Message
From
12/05/2007 18:08:43
Jeff Corder
Ambit Technologies, LLC
Missouri, United States
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Generics as Properties & Parameters
Miscellaneous
Thread ID:
01225008
Message ID:
01225008
Views:
75
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
Next
Reply
Map
View

Click here to load this message in the networking platform