Created
December 16, 2009 16:52
-
-
Save leongersing/257978 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C# version of a class and it's instances (objects) | |
public class Person{ | |
public string Name{get;set;} | |
public string Email{get;set;} | |
public int Age{get;set;} | |
public string Sex{get;set;} | |
} | |
public class Man : Person{ | |
public Man{ | |
Sex = "male"; | |
} | |
} | |
public class Woman : Person{ | |
public Man{ | |
Sex = "female"; | |
} | |
} | |
Person person = new Person(); | |
person.Name = "Leon"; | |
person.Email = "foo@foo.com"; | |
person.Age = 32; | |
Man leon = new Man(Name="Leon", Email="foo@foo.com", Age=32); | |
Console.WriteLine(leon.Sex); // it's a boy! :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment