Welcome to MSDN Blogs Sign in | Join | Help

jaredpar's WebLog

Code, rants and ramblings of a programmer.

Syndication

News

Now Reading

Pragmatic Programmer

Pragmatic programming at it's best. The book is a light read and worth the time

Essential WPF

Thus far the best book I've read on WPF. Gets right down to working with WPF and the goals/history.

Purely Functional Data Structures

Reading this book makes me feel like I'm back in college. It will really get your mind going and is best read with a whiteboard handy.


Browse by Tags

All Tags » Generics   (RSS)
Gotcha: Generic overload resolution when called generically
Both VB and C# have a feature of generic overload resolution that is fairly helpful and yet a source of gotchas. Lets say you have two methods with the same number of arguments. One method has arguments with generic types and the other does not. For Example: Read More...

Posted Monday, April 14, 2008 8:30 AM by Jared Parsons | 1 Comments

Filed under: , ,

Design Guidelines: Provide type inference friendly Create function for generic objects
Really this guideline is a bit longer but putting it all in a blog title seemed a bit too much.  The full guideline should read: "If a generic class constructor arguments contain types of all generic parameters, provide a static method named Read More...

Posted Friday, April 11, 2008 8:24 AM by Jared Parsons | 3 Comments

Filed under: , , ,

Have an IComparer<T> but need an IComparable<T>?
Previously we discussed the opposite problem.  This is a lesser but often more frustrating problem because there is no, AFAIK, built in solution for the BCL.  However it's problem that can be solved once and reused with a generic solution. IComparable<T> Read More...

Posted Wednesday, April 09, 2008 8:20 AM by Jared Parsons | 0 Comments

Filed under: , ,

Tuples Part 8: Finishing up
There are only a few missing features from our tuple implementation.  Mainly FxCop compliance, debugging support and test case code.  The actual functional work is complete.  The one issue with FxCop compliance is the chosen names.  Read More...

Posted Sunday, January 27, 2008 9:37 PM by Jared Parsons | 1 Comments

Filed under: , , , ,

Tuples Part 6: Comparing
Part 5 produced equality tests for Tuples. This section will add comparison support through the IComparable<T> interface. Implementing comparable is very similar to adding equality support. Once again there is a generic class available to make all Read More...

Posted Tuesday, January 22, 2008 1:56 AM by Jared Parsons | 3 Comments

Filed under: , , ,

Tuples Part 5: Equality
Part 4 left us with a reusable, abstract and inference friendly Tuple class.  The next step is to be able to test for Tuple equality.  For the Tuple implementation, two tuples will be defined as equal if all of their members are equal.  Read More...

Posted Tuesday, January 22, 2008 1:31 AM by Jared Parsons | 2 Comments

Filed under: , ,

C# Lambda Type Inference
One of the limitations of C# type inference is that you cannot use it to infer the type of a lambda expression. For example, the following code will not compile var f = () => 4; Normally this is not too much of an issue because you can just explicitly Read More...

Posted Friday, December 14, 2007 12:41 PM by Jared Parsons | 1 Comments

Type Inference and IEnumerable
This is somewhat of a follow up on a previous post I did on the difference between IEnumerable(Of T) and the IEnumerable interfaces. I've seen several people type in the following code and wonder if there was a fundamental bug in the type inference code. Read More...

Posted Monday, November 26, 2007 5:32 PM by Jared Parsons | 2 Comments

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 Read More...

Posted Friday, November 09, 2007 7:46 PM by Jared Parsons | 0 Comments

Filed under: , ,

IEnumerable and IEnumerable(Of T) 2
Quick follow up to my earlier post . Fixing this issue in C# is even easier because of the existence of iterators. public static IEnumerable < object > Shim(System.Collections. IEnumerable enumerable) { foreach ( var cur in enumerable) { yield return Read More...

Posted Friday, October 05, 2007 11:43 AM by Jared Parsons | 3 Comments

Filed under: , ,

IEnumerable and IEnumerable(Of T)
IEnumerable(Of T) is a huge step up in the 2.0 framework from the original IEnumerable interface. It provides a typed enumeration which eliminates lots of nasty casts. The best part is that IEnumerable(Of T) is backwards compatible with IEnumerable (it Read More...

Posted Thursday, October 04, 2007 2:29 PM by Jared Parsons | 4 Comments

Filed under: ,

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 Read More...

Posted Monday, October 01, 2007 11:15 AM by Jared Parsons | 4 Comments

Filed under: , ,

Singleton Pattern
Quite awhile back I posted about how to create a re-usable singleton pattern in .Net. Link is here . A bit of time has passed and I've altered the pattern a bit. The reasons for the change are some new type inference patterns and FxCop cleanliness. The Read More...

Posted Tuesday, September 04, 2007 1:58 PM by Jared Parsons | 3 Comments

Filed under: , , ,

Page view tracker