tags:

views:

222

answers:

4

I am really curious to know how the Expando Object in .Net 4.0 has been internally implemented?

Thanks in advance

+1  A: 

Use Reflector, which now supports .Net 4.0.

SLaks
Don't you mean which *now* supports .Net 4.0?
Billy ONeal
@Billy: Yes, I do; thank you very much.
SLaks
+1  A: 

It's implemented as a dictionary internally.

Check out Alexandra Rusina's blog on the topic here, and mine here.

David Morton
@David: just wondering if you are you colour blind? The colours on your blog glare on an LCD monitor.
Mitch Wheat
Sorry Mitch, no, I'm not color blind. What do you mean they glare?
David Morton
Looks fine to me...
Joel Mueller
@David: it implements IDictionary<> but it doesn't use a dictionary. I left a link to the source code in my post.
Hans Passant
A: 

The sure way to find out is use Reflector v6: .NET Reflector demonstration video

Mitch Wheat
+3  A: 

You don't have to mess with Reflector, the source code for the DLR is readily available for download here. Nicely commented too. You'll find the source code for ExpandoObject in src\Runtime\Microsoft.Scripting.Core\Actions\ExpandoObject.cs

The data store for an ExpandoObject is an ExpandoData, available in the same source file. The values are stored in a simple object[]. The ExpandoClass (same directory) keeps track of the keys in a simple string[]. ExpandoObject definitely doesn't use a Dictionary as earlier stated, but it does implement IDictionary.

Hans Passant