>>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