复制代码 代码如下:
using System;
using System.Collections.Generic;
using System.Text;
namespace 属性的用法
{
public class Student
{
private string stuCollege = "jyu";//学校名称不可修改
private string stuName = "阿会楠";
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 "学校:" + stuCollege + "名字:" + stuName + "岁数:" + stuAge;}
}
}
class Program
{
static void Main(string[] args)
{
Student stu = new Student();
Console.Write(stu.studentCollege + "/n");
stu.studentAge = 25;
Console.Write(stu.studentInfo);
Console.ReadKey();
}
}
}
新闻热点
疑难解答
图片精选