首页 > 其他 > 详细

创建和继承单例基类

时间:2020-07-11 12:28:05      阅读:59      评论:0      收藏:0      [点我收藏+]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PoolMar : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

public class Student <T> where T:new()  
{
    public static T instance;

    public static T MyStudent() 
    {
        if (instance == null)
        {
            instance = new T();
        }

        return instance;
    }
}

public class Student1 :Student<Student1>
{

}

 

创建和继承单例基类

原文:https://www.cnblogs.com/yueqingli/p/13282985.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!