Tag: anonymous type

Example of Anonymous Type Indexes in For Loop in C#

The anonymous type (var) can be used to initialize the indexes in a for loop or the object within the for each loop. Below is a sample code snippet demonstrating the usage of the anonymous types in the For loop . Example of Anonymous Type Indexes in For Loop in C#

How to Get the Name of the Anonymous class(type) in C# ?

Below is a sample code snippet which gets the name of the anonymous class . In the below example , the Name and the ID property is set which is anonymous where the type is not specified. When trying to find out the type of the anonymous type , you will get the type as shown in the screenshot below. How to Get the Name…

Example of Composite Anonymous Types in C#

The feature of anonymous types can be felt specially when we work with the composite type rather than the simple types. The below example is more like you are defining an inline class without actually having the definition. Example of Composite Anonymous Types in C# Below is an example of the anonymous type in C# that demonstrates the composite anonymous type. Note that you will…

Rules for using Anonymous Types in C#

The anonymous types (var) in C# is an interesting feature that the C# developers could use within their .NET application . When using the anonymous type , there are certain criteria or rules that needs to be followed . Rules for using Anonymous Types in C# Below are some of the rules that the developers should be following when using the anonymous type. 1. NULL…