Browse by Tags
All Tags »
Type Inference (RSS)
While updating my VsVim editor extensions for Beta2 [1] I got hit by a change in the way F# exposed discriminated unions in metadata. My extension consists of a core F# component with a corresponding set of unit tests written in C#. It’s mostly
Read More...
Occasionally the debate will come as to when it's OK to use type inference in order to declare a variable. There appear to be three groups in this debate. Whenever it's possible Only when it's absolutely clear what the type is Never, type inference
Read More...
One action I find frustrating in C# is where a particular action needs to be taken based off of the type of a particular object. Ideally I would like to solve this with a switch statement but switch statements only support constant expressions in C# so
Read More...
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...
Last time we were left with a constructor that required us to explicitly specify generic parameters. This is not always easy or possible. We'll now alter the script to generate a constructor which utilizes type inference to create a Tuple. In addition,
Read More...
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...
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...