General form of C# Object Initializers
C# has a language feature that allows several properties of an object to be assigned to as a suffix to a new expression, namely the object initializer:
Read more…
C# has a language feature that allows several properties of an object to be assigned to as a suffix to a new expression, namely the object initializer:
Read more…
I don’t think there’s anything in LINQ that will do this, though I expect I’m wrong – I have a tendency to write my own extension method to do something and then discover that LINQ already provides a general version of it. But in the mean time, here’s my Chain method:
Is there something like this in the standard libraries? And if not, why not?
It is an important and popular fact that properties in C# can be defined in interfaces. For example:
public interface IThing { IThing Parent { get; } }
We can then implement that interface on a concrete class:
It worries me that the using keyword doesn’t have enough meanings already! But coming from a C++ background I’m very keen on the using (…) { scope } syntactic sugar. It helps with clients of IDisposable objects. But so far, it provides no help for implementors. So my suggestion is to allow the using keyword to act as a modifier on member variables.
Simple example:
class B { using FussyResource X; }
is equivalent to: