3
When I saw the use of expression new {}
I remembered Javascript, where I use new Object
and {}
are equivalent.
Just for study purposes, I made some comparisons, to see if Csharp followed the same idea of Javascript, but it seems I was wrong:
var obj1 = new {};
var obj2 = new object(){
};
Console.WriteLine(obj1.GetType()); // <>f__AnonymousType0
Console.WriteLine(obj2.GetType()); // System.Object
In this case, what is the name given to new {}
, since it doesn’t seem to be the same thing as object
?
What is the relationship of new {}
with object
in C#?