Anonymous Type of an existing type
I find the .NET anonymous type a bit weak in terms of a few more features:
- Can't inherit/implement an existing type
var x = new : IMyInterface {
Number = 1,
Name = "Hi",
}; - Can't add methods
var x = new {
Number = 1,
Name = "Hi",
Action = delegate(object o){ return true; },
}
I guess anonymous types are purely for quick throw-away data constructs. I might just as well write a class directly with all the stuff I wanted.