Public class Photo {
Private int _ id;
Private int _ albumid;
Private string _ caption;
Public int PhotoID {get {return _ id ;}
Set {this. _ id = value ;}}
Public int AlbumID {get {return _ albumid ;}
Set {this. _ albumid = value ;}}
Public string Caption {get {return _ caption ;}
Set {this. _ caption = value ;}}
Public Photo (int id, int albumid, string caption ){
_ Id = id;
_ Albumid = albumid;
_ Caption = caption;
}
}
In general, get is used to obtain the value. set is used to set the value.
For example, get {return _ id ;}
If you call this get method, you can obtain this. _ id = value (returned value) of the return method)
Call method: Console. Write (object _ id); (output value of this attribute)
For example, set {this. _ id = value ;}
If you call this set method, You can reset the value of _ id, Which is the value you set.
Call method: object. _ id = "New Value"; (attaches a new value to this attribute)