Top "Anonymous-types" questions

Anonymous types are data types which dynamically add a set of properties into a single object without having to first explicitly define a type

A generic list of anonymous class

In C# 3.0 you can create anonymous class with the following syntax var o = new { Id = 1, Name = "Foo" }; Is there a …

c# .net generics anonymous-types
Can anonymous class implement interface?

Is it possible to have an anonymous type implement an interface? I've got a piece of code that I would …

c# anonymous-types
How to pass anonymous types as parameters?

How can I pass anonymous types as parameters to other functions? Consider this example: var query = from employee in employees …

c# function parameters anonymous-types
How to dynamic new Anonymous Class?

In C# 3.0 you can create anonymous class with the following syntax var o1 = new { Id = 1, Name = "Foo" }; Is there a …

c# c#-3.0 anonymous-types
How do I serialize a C# anonymous type to a JSON string?

I'm attempting to use the following code to serialize an anonymous type to JSON: var serializer = new DataContractJsonSerializer(thing.GetType()); …

c# json anonymous-types datacontractjsonserializer json-serialization
Accessing constructor of an anonymous class

Lets say I have a concrete class Class1 and I am creating an anonymous class out of it. Object a = …

java constructor overloading anonymous-types
How to access property of anonymous type in C#?

I have this: List<object> nodes = new List<object>(); nodes.Add( new { Checked = false, depth = 1, id = "…

c# .net object properties anonymous-types
Returning anonymous type in C#

I have a query that returns an anonymous type and the query is in a method. How do you write …

c# .net anonymous-types return-type
Declaration of Anonymous types List

Is there any way to declare a list object of anonymous type. I mean List<var> someVariable = new …

c# asp.net c#-3.0 anonymous-types
LINQ Select Distinct with Anonymous Types

So I have a collection of objects. The exact type isn't important. From it I want to extract all the …

c# linq distinct anonymous-types equality