An Anonymous Type Assigned to a Variable Declared with the var Keyword : var « LINQ « C# / C Sharp






An Anonymous Type Assigned to a Variable Declared with the var Keyword

 


using System;
public class MainClass {
    public static void Main() {
        var unnamedTypeVar = new { firstArg = 1, secondArg = "Joe" };
        Console.WriteLine(unnamedTypeVar.firstArg + ". " + unnamedTypeVar.secondArg);

    }
}

 








Related examples in the same category

1.Using var
2.Anonymous Types
3.Instantiating and Initializing an Anonymous Type Using Object Initialization
4.An Example of Collection Initialization