When I saw the use of the 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 as 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 does not seem to be the same as object
?
What is the ratio of new {}
to object
in C #?