Confused about a bit of code

tuhin01

New member
Joined
May 3, 2015
Messages
1
Programming Experience
1-3
I need someone to help me understanding this bit of c# code:

[FONT=Open Sans, Verdana, Geneva, sans-serif, sans-serif]public Teacher[] Teachers { get; set; }[/FONT]

[FONT=Open Sans, Verdana, Geneva, sans-serif, sans-serif]I can see this is an array but is it ok to use get, set here instead of :

[/FONT]public Teacher[] Teachers = new Teacher[4];
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
3,136
Location
Sydney, Australia
Programming Experience
10+
The getter and setter indicate that Teachers is a property rather than a field. Properties are intended to behave like fields from the outside but like methods from the inside. You should research more on that subject specifically.
 
Top Bottom