Articles → .NET → Anonymous type in .Net 3.0

Anonymous type in .Net 3.0











var person = new { Name = "Karan", Age = 29 };






private void Window_Loaded(object sender, RoutedEventArgs e) {
	var person = new {
		Name = "Karan",
		Age = 29
	};
	MessageBox.Show(person.Name);
	MessageBox.Show(person.Age.ToString());
}




class __Anonymous1 {
	private string name;
	private int age;
	public string Name {
		get {
			return name;
		}
		set {
			name = value;
		}
	}
	public int Age {
		get {
			return age;
		}
		set {
			age = value;
		}
	}
}
__Anonymous1 p1 = new __Anonymous1();
p1.Name = "Karan";
pt.Age = 29



Posted By  -  Karan Gupta
 
Posted On  -  Monday, January 25, 2010

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250