Simple understanding of my properties (C #)

xiaoxiao2021-03-20  209

/ / ==================== GET accessor ========================== ============== GET Accessor is used to return a field value

CLASEE PERSON {private int number; public int number {// can write some own function get {return number;}}} When the value in the property is to be accessed, use Person P1 = New Person (); system.console.write P1.NUMBER);

/ / ===================== SET accessor ========================= =====================

The Set Accessor is used to add the value to the value of Class Person {Private String name; public string name {get {return name;} set {name = value;}}}

// Read the value in the read and write attribute Person P1 = new person (); p1.name = "Song" // Set the value in the property system.console.write (p1.name); // Read the value in the properties

转载请注明原文地址:https://www.9cbs.com/read-130343.html

New Post(0)