CSharpFeeds - All your C# feeds in one place.

Sponsors

Tuesday, June 16, 2009

C#4.0: clearing up some doubts

by luisabreu via LA.NET [EN] on 6/16/2009 3:53:29 PM

After my last post on C# 4.0, I’ve had an interesting exchange of tweets with Thomas Johansen about the usefulness of the code I’ve shown. As Thomas points out, knowing the type means that you should always cast it to that type so that you work with strongly typed verification (ie, compile time checking). In practice, what he’s saying is that example is completely useless because if you know the type of the object you’re creating, then you should always cast it to that type before using it.

I do  agree with him and that’s why I’ve ended up writing this post so that there isn’t any doubt regarding what you should do: whenever possible, you should work with the type instead of relying in dynamic types or in reflection.

Since I’ve already published the code, what I’d really like is that you concentrate only in the dynamic usage parte and read the CreateInstance invocatio as GetMeADynamicObjectFromSomewhereWhichHasSeveralKnownProperties. Can you guys do that? thanks :)


email it!bookmark it!digg it!

Original Post: C#4.0: clearing up some doubts

Subscribe

New Feed

Product Spotlight

Recently Updated Sources

Legal Note

The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.

Advertise with us