Lance Ahlberg's WebLog

Reflection on reason

Reflecting on generic types

I've recently been having fun trying to get the type of a generic list using reflection.

The VS2005 MSDN doco suggests trying something like..

Type classType = Type.GetType(“System.Collections.Generic.List[[System.String,Mscorlib]],Mscorlib“,true);

I kept getting a a TypeLoadException : Could not load type 'System.Collections.Generic.List' from assembly mscorlib.

After a bit of deliberating, I decided to try the following..

System.Collections.Generic.List<String> stringList = new System.Collections.Generic.List<String>();

Type classType = stringList.GetType();

Console.WriteLine(classType.ToString());

Guess what I got...

System.Collections.Generic.List`1[System.String]

So what is this `1 about, it seems to be added to generic classes. 

From a bit more investigation it seems to represent the number of generic parameters (dimensions) associated with the class, so Dictionary is Dictionary`2.  While a generic class like MyGeneric<A,B,C,D,E> is actual MyGeneric`5.

 

Comments

TrackBack said:

# June 2, 2004 12:50 AM

cheap Louis Vuitton handbags said:

Nice post. My friend John told me about this blog some weeks ago but this is the first time Im visting. Ill undoubtedly be back.

# July 22, 2011 8:12 PM

chaussure Nike Air Max said:

I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! keep up the good work. I am always trying to foster good relationships with people who can help my cause. <a href="www.chaussurenikeairmaxpascher.com/" title="chaussure Nike Air Max">chaussure Nike Air Max</a>This really breaks it down to a step by step process

# July 24, 2011 10:35 PM

Cheap Supra Footwear said:

I agree with your Blog and I will be back to check it more in the future so please keep up your work. I love your content & the way that you write. It looks like you have been doing this for a while now, how long have you been blogging for?<a href="www.supratksocietyblue.com/" title="Cheap Supra Footwear">Cheap Supra Footwear</a>

# July 26, 2011 10:00 PM

supra tk society said:

You managed to hit the nail upon the top as well asand alsoand defined out the whole thing without having side effectside-effects , people cancould take a signal. Will likelyprobably be back to get more. Thanks!<a href="www.supratksocietysale.com/" title="supra tk society">supra tk society</a>

# July 28, 2011 10:16 PM

cheap Burberry outlet said:

Easy option to get useful information as well as share good stuff with good ideas and concepts.<a href="www.cheap-burberryoutlet.com/" title="cheap Burberry outlet">cheap Burberry outlet</a>

# August 2, 2011 11:53 PM

Monster beats studio said:

I always enjoy your posts, your real, and some times funny as well. keep it up!<a href="www.cheapmonsterbeatsheadphones.com/" title="Monster beats studio">Monster beats studio</a>

# August 3, 2011 12:02 AM

Cheap Supra Footwear said:

You raise many questions in my head; you wrote a good post, but it is also thought provoking, and I will have to ponder it some more; I will return soon.<a href="www.supratksocietyblue.com/" title="Cheap Supra Footwear">Cheap Supra Footwear</a>

# August 4, 2011 9:13 PM

Canada Goose sale said:

Resources like the one you mentioned here will be very useful to me! I will post a link to this page on my blog.<a href="www.canadiangooseonsale.com/" title="Canada Goose sale">Canada Goose sale</a>

# August 7, 2011 10:12 PM

cheap louis vuitton bags said:

Wonderful learn, I simply passed this onto a colleague who was in search of this info. I've you bookmarked on Digg.<a href="www.cheaplouisvuittonbagsonline.com/" title="cheap louis vuitton bags">cheap louis vuitton bags</a>

# August 10, 2011 2:30 AM

cheap north face jackets said:

I continue to read blogs like this, because I am trying to better my ability to write great content, this is an awesome example.<a href="www.cheapnorthfaceoutlets.com/" title="cheap north face jackets">cheap north face jackets</a>

# August 10, 2011 5:47 AM

wholesale caps said:

Comfortably, the article is in reality the best on this valuable topic. I harmonise with your conclusions and will thirstily look forward to your coming updates.<a href="www.wholesale-caps-shop.com/" title="wholesale caps">wholesale caps</a>

# August 11, 2011 3:15 AM

Ralph Lauren outlet said:

Iam glad l came across this post, very educating. I will subscribe to your rss for future update.<a href="www.ralph-laurenoutletonline.com/" title="Ralph Lauren outlet">Ralph Lauren outlet</a>

# August 12, 2011 5:27 AM

buy nike air max said:

I loved reading this article  I will be sure to tell my friends about this and link to it as well. Thanks!<a href="www.buynike-airmax.com/" title="buy nike air max">buy nike air max</a>

# August 12, 2011 10:54 PM

coogi clothing said:

The theme is really attractive. Congratulations to the author of the blog!

# August 13, 2011 3:28 AM

Gucci outlet store said:

This is one of the best post I have ever read, I would love to read more in future. Keep up the good work.<a href="www.buyguccioutlet.com/" title="Gucci outlet store">Gucci outlet store</a>

# August 15, 2011 8:55 PM

cheap prada handbags said:

Easily, the post is in reality the sweetest on this deserving topic. I concur with your conclusions and will eagerly look forward to your approaching updates.<a href="www.cheappradahandbagsonline.com/" title="cheap prada handbags">cheap prada handbags</a>

# August 17, 2011 11:04 PM

buy nike air max said:

I loved reading this article  I will be sure to tell my friends about this and link to it as well. Thanks!<a href="www.buynike-airmax.com/" title="buy nike air max">buy nike air max</a>

# August 18, 2011 5:38 AM

rtyecript said:

I really liked the article, and the very cool blog

# August 24, 2011 5:00 AM

Buy oem said:

4YOaEM I envy you. The content and design of your blog is much better than mine. Who made a design for you?!...

# September 24, 2011 10:27 AM

Buy software said:

EpN24A I do`t regret that spent a few of minutes for reading. Write more often,  surely'll come to read something new!...

# October 27, 2011 1:57 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)