Create Anonymous Type in CSharp
Description
The following code shows how to create Anonymous Type.
Example
/*w ww .j av a2 s.com*/
using System;
using System.ComponentModel;
class MainClass
{
static void Main()
{
var tom = new { Name = "Tom", Age = 4 };
var holly = new { Name = "Holly", Age = 31 };
var jon = new { Name = "Jon", Age = 31 };
Console.WriteLine("{0} is {1} years old", jon.Name, jon.Age);
}
}
The code above generates the following result.