Click here to Skip to main content
15,916,949 members
Articles / Programming Languages / C#

Get Anonymous Object Properties using Inferred Casting

Rate me:
Please Sign up or sign in to vote.
3.67/5 (3 votes)
3 Apr 2010CPOL 11.2K   1  
Ever wonder how to get at the Properties of an Anonymous Object without Reflection? If you know the data Types of the properties, here is an Extension to the Object object that allows you to do just that: public static T InferCasting(this object o, T example) { ...

Views

Daily Counts

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Serexx Ltd.
Canada Canada
In '97 or so I started fiddling around with this new thing called the Internet. Mistake.

I blinked and found myself in 2000 ditching my Accounting designation and starting to write code for a living - mostly ASP Classic back then along with some C++ and a little assembler, PHP, Perl/CGI (ouch) and of course Javascript and most of the other web-side tools.

With v3.0 .Net finally became something I couldn't ignore and so here I am still coding - WinForm, ADO, SQL, .Net, and WPF shortly, no doubt to be followed by Silverlight and maybe some MVC.

"Teach me, learn or get out of the way."

Comments and Discussions