当前位置:编程学习 > C#/ASP.NET >>

base参数问题

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace lt4_8
{
    class Student
    {
        public static string sClassName = "软件班";
        public string SName = "王丽";
        private int Age = 6;
        protected string Sex;
        public void WriteAge()
        {
            Console.WriteLine(this.Age);
        }
        private void WriteSName()
        {
            Console.WriteLine(SName);
        }
    }
    class CStudent : Student
    {
        private string Department;
        public CStudent(string _Department, string _SName, string _Sex):base(22,"赵六")
        {
            Department = _Department;
            SName = _SName;
            Sex = _Sex;
        }
        public void WriteCStudentInfo()
        {
            Console.Write("{0},{1},{2},{3},", SName, Sex, Department, sClassName);
            WriteAge();
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            CStudent cstu1 = new CStudent("计算机系", "张三", "男");
            cstu1.WriteCStudentInfo();
            Console.ReadLine();
        }
    }
}
 [img=C:\Documents and Settings\Administrator\桌面][/img] --------------------编程问答-------------------- student类加上

        public Student(int age, string sname)
        {
            Age = age;
            SName = sname;
        } --------------------编程问答-------------------- 楼主想问什么都没说啊
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,