With a Person class, how do I go about representing Gender, I want to create it as a class, much like the System.Drawing.Color setup, but I am unsure how to do this.
So I can do Gender = Gender.Male or Gender = Gender.Female etc.
Sorry if this makes no sense.
You could create an enum:
public enum Gender { Male, Female }
and then use it as below:
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public Gender Gender { get; set; }
}
var person = new Person
{
FirstName = "Foo",
LastName = "Bar",
Gender = Gender.Male
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With