But even more often, I find myself wishing C# blocks were expressions.
In F#, I could do this:
let x =
let z = whatever
...
value
and z is inside a local scope.So in C#, I want to do:
var x =
{
var z = whatever;
...
value
};
Maybe it's just me. var x = (() =>
{
var z = whatever;
...
return value;
})();
It is not the most performant way to write that code and if the contents start to get long, refactoring to its own method starts to feel more likely, but in one-off cases, it seems fine for how ugly it is.for instance, as an example for this https://fsharpforfunandprofit.com/posts/designing-for-correc... where a C# solution is suggested and done with DUs in F#, I wrote the equivalent DU solution in C#... https://gist.github.com/keithn/ceeeed5f7eb567e1b2333747065d1...
Only thing you don't have is exhaustive checking, which I personally don't think is much of a problem pragmatically.
There's a secondary benefit though if they allow DUs of Structs where you can have it be on the stack as a single value based on the size of the largest subtype that could be incredibly useful when you are worried about performance. Inheritance does not do that.