Is there any difference between `new object()` and `new {}` in c#?

anonymous-types, c#, syntax

Solution

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.

Problem

in c#, ``` var x = new {}; ``` declares an anonymous type with no properties. Is this any different from ``` var x = new object(); ``` ?

Original source

Related problems