⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 program.cs

📁 C#2.0宝典源码,C#经典书籍,很多例子
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;

namespace Example7_9 {
    class Program {
        static void Main(string[] args) {
            Student zhang = new Student();
            zhang.MyChinese = 96;
            Console.WriteLine("语文成绩为:{0}", zhang.MyChinese);
            zhang.MyMath = 92;
            Console.WriteLine("数学成绩为:{0}", zhang.MyMath);
            Console.WriteLine("总成绩为:{0}", zhang.AllScore());
            Console.WriteLine("平均成绩为:{0}", zhang.AverageScore());
            zhang.Higher();
            Console.ReadLine();
        }
    }

    /// <summary>
    /// 学生类
    /// </summary>
    class Student {
        double myMath = 0;
        double myChinese = 0;

        /// <summary>
        /// 数学成绩属性,可读写
        /// </summary>
        public double MyMath {
            get {
                return myMath;
            }
            set {
                myMath = value;
            }
        }

        /// <summary>
        /// 语文成绩属性,可读写
        /// </summary>
        public double MyChinese {
            get {
                return myChinese;
            }
            set {
                myChinese = value;
            }
        }

        /// <summary>
        /// 求两门课总成绩
        /// </summary>
        /// <returns>两门课总成绩</returns>
        public double AllScore() {
            return myChinese + myMath;
        }

        /// <summary>
        /// 求两门课平均成绩
        /// </summary>
        /// <returns>平均成绩</returns>
        public double AverageScore() {
            return (myChinese + myMath) / 2;
        }

        /// <summary>
        /// 输出成绩高的课程
        /// </summary>
        public void Higher() {
            Console.WriteLine("成绩高的课程是:{0}", myMath > myChinese ? "数学" : "语文");
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -