The property of anonymous type is inferred from the expression.
using System;
class Test
{
static void Main()
{
string FirstName = "J";
var person = new { FirstName };
// var person = new {FirstName = "J"};
Console.WriteLine(person.FirstName);
}
}
The output:
J