BusinessRx Community

Dedicated to the advancement of software, technology and the people who devote their lives to it.

Welcome to BusinessRx Community Sign in | Join | Help
in Search

BusinessRx Reading List

These blog entries are written by industry experts and leaders. We consider this content to be a good read for any software developer or web technologist.

Using Reflection (and O/R Mappers) with Nested Classes

I can't say that I've ever used a nested class myself, but I recently had a problem posted to my forums that involved a nested class and my ORMapper.  I tested it myself and concluded that it was a bug due to my never having worrying about it before.  Well it wasn't easy to find the solution, but I'm happy to report that there was no bug at all -- you just have to know the trick that .NET expects when using nested classes with reflection.  It turns out that you should use a plus sign (+) instead of a dot (.) when referring to the nested class in a type name that you are going to reflect on -- so something like this:  "Name.Space.Main+Nested".  Its even in the MSDN docs here, although its not in other parts of the MSDN docs that I was originally looking for it at, like here.  Anyhow, I assume this information will be useful to anyone using reflection with nested classes, and it probably applies to other O/R Mappers also, so it seemed worthy of posting on this blog.
Share this post: Email it! | bookmark it! | digg it! | reddit!
Published Monday, April 10, 2006 10:51 AM by Paul Wilson's .NET Blog

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server, by Telligent Systems
'