Object initialization 01 (working)

CSharp · Console

/Program.cs

using System;
		
public class Type1 {
	public string Prop1 { get; set; }
	public Type2 Prop2 { get; set; }
}

public class Type2 {
	public string Prop { get; set; }
}

public class Program
{
	public static void Main()
	{
		
		Type1 testObj = new Type1 { 
			Prop1 = "TEST",
			Prop2 = new Type2 { Prop = "TEST2" }
			
		};
		
		Console.WriteLine("{0} {1}", testObj.Prop1, testObj.Prop2.Prop);
	}
}
;