1 class student 2 { 3 public int _code; 4 public int Code//属性 5 { 6 //获取值 7 get 8 { 9 return 5; 10 } 11 //设置值 12 set 13 { 14 _code = value + 9; 15 } 16 } 17 private string _name; 18 public string Name 19 { 20 get { return _name; } 21 set { _name = value; } 22 } 23 } 24 25 student s = new student(); 26 s.Code = 3; 27 Console.WriteLine(s.Code); 28 Console.WriteLine(s._code); 29 Console.ReadLine();
时间: 2024-10-09 05:55:23