SoFunction
Updated on 2025-04-13

Use of get set


using System; 
using ; 
using ; 

namespace attribute usage

    public class Student 
    { 
private string stuCollege = "jyu";//The school name cannot be modified
private string stuName = "Ah Huinan";
        private int stuAge = 22; 
        public string studentName 
        { 
            get { return stuName; } 
            set { stuName = value; } 
        } 
        public int studentAge 
        { 
            get { return stuAge; } 
            set { stuAge = value; } 
        } 
        public string studentCollege 
        { 
            get { return stuCollege; } 
        } 
        public string studentInfo 
        { 
get { return "School: " + stuCollege + "Name: " + stuName + "Age: " + stuAge;}
        } 
    } 
    class Program 
    { 
        static void Main(string[] args) 
        { 
            Student stu = new Student(); 
            ( + "\n"); 
             = 25; 
            (); 
            (); 
        } 
    }