in c#,
var x = new {};
declares an anonymous type with no properties. Is this any different from
var x = new object();
?
Yes, the types used are different. You can tell this at compile-time:
var x = new {};
// Won't compile - no implicit conversion from object to the anonymous type
x = new object();
If you're asking whether new{}
is ever useful - well, that's a different matter... I can't immediately think of any sensible uses for it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With