c# 静态构造函数

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

namespace ConsoleApp32
{
    class Program
    {
        static void Main(string[] args)
        {
            var child = new Child(60);
            Console.Read();
        }

    }
    public class Parent
    {
        public Parent(string args)
        {
            Console.WriteLine(args);
        }
    }
    public class Child : Parent
    {
        public Child(int i) : base (JudgeValue(i))
        {

        }
        private static string JudgeValue(int value)
        {
            if (value >= 60)
            {
                return "及格";
            }
            else
            {
                return "不及格";
            }
        }
    }
}

作者:spike

分类: Net

创作时间:2023-06-25

更新时间:2024-12-09

联系方式放在中括号之中例如[[email protected]],回复评论在开头加上标号例如:#1