Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding Properties to an object at run time
Message
De
04/02/2011 20:12:11
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 3.0
Divers
Thread ID:
01498603
Message ID:
01498852
Vues:
38
>>I think Viv's idea of a dictionary is a good one, but I'd go one step further and use an enum rather than a string.
>>
>
>But if you're going to do that, why not just create a wrapper class that does all of the casting for you in the first place?


Yes, I suppose so ... I was just trying to think of a quickie alternative. <g>

>Or, if you can upgrade, just use the new Expando object.

I remember hearing about the new Dynamic stuff in .NET 4 last year, but haven't had the time to play with it at all. One of these days I suppose I should explore it.

>(honestly, I just use this class from Rick Strahl: http://www.west-wind.com/wwAppConfiguration/ which handles all of that automatically).

Ah, but I have a long history of writing my own .NET stuff rather than pay for classes/frameworks that have already had all the bugs worked out. I'd rather play by my own rules than someone else's I guess. <g>

(That was, more or less, tongue-in-cheek. I'm saying that to ward off the scads of people who are going to reply and suggest that buying pre-built is better than developing roll-your-own. I have, on occasion, plunked down money for something useful that I didn't feel like re-inventing <g>)

~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform