Code, rants and ramblings of a programmer.
Browse by Tags
Tagged Content List
Dictionary<TKey,TValue>.TryGetValue and Anonymous Types
One of the methods I find to be the most useful in .Net is the method Dictionary<TKey,TValue>.TryGetValue . This method is a nice compromise between performance, explicit return vs. exception, and a being verbal about the chance of failure. It returns false on failure and uses an out...
23 Mar 2010
Names of Anonymous Type Members
Recently I was asked how can you get a list of anonymous type member names given a query of anonymous types. The quick answer is that you can use a quick bit of reflection to get back the names. Public Function GetAnonymousTypeMemberNames( Of T)( ByVal anonymousType As T) As List( Of String ) Dim type...
9 Nov 2007
Casting to an Anonymous Type
This discussion is building upon a previous post on how to acquire an anonymous type ... type . The next question is, how can you cast an arbitrary object into an anonymous type? At a glance this doesn't seem possible as you cannot directly express the type of an anonymous type in code. For instance...
1 Oct 2007
Coding Quiz: Anonymous Type Types
Question: How can you create a variable in VB which is typed as an anonymous type but not actually create an instance of that type? Answer in comments. Note, doing this is not particularly useful it came about while I was playing around with a feature a few days ago.
1 Aug 2007
Page 1 of 1 (4 items)
© 2015 Microsoft Corporation.
Privacy & Cookies