Hi I have recently started to learn C# and have some questions regarding properties.
Let’s say I have this statement:
private int minAge { get; set; }
Does this translate into this:
private int minAge
public int MinAge
{
get { return this.minAge; }
set { this.minAge = Convert.ToInt16(TextBox1.Text); } //this is what I would like to set the field to
}
Let’s say that I have a button and when I press that button I need it to set the minAge field and after that return the data.How can I achieve this?
I tried this but it does not seem to work:
minAge.get //to return data
minAge.set = Convert.ToInt16(TextBox1.Text); //to set the data
What you just do is to public your property:
Then you can use for get and set (implicitly):