51
Yes, it is possible to declare a class inside a class and these are called inner classes
public class Foo
{
public class Bar
{
}
}
and this how you can create an instance
Foo foo = new Foo();
Foo.Bar bar = new Foo.Bar();
And within a method you can create an object of anonymous type
void Fn()
{
var anonymous= new { Name="name" , ID=2 };
Console.WriteLine(anonymous.Name+" "+anonymous.ID);
}