C#的接口与抽象类 2023-01-19 26 笔记 ```csharp using System.Collections; using System.Collections.Generic; using UnityEngine; public class Player : MonoBehaviour { MagicApprentice apprentice = new("Marisa"); public void Start() { apprentice.TellName(); apprentice.Ino(); } } interface IApprentice { public void TellName() { } } abstract class Magic { public abstract void Ino(); } //抽象类在接口之前继承 class MagicApprentice : Magic, IApprentice { private string name; public override void Ino() { Debug.Log("Master Spark!"); } public MagicApprentice(string name) { this.name = name; } public void TellName() { Debug.Log("I'm " + name); } } ``` 需要注意的一点放在注释了。 本文链接: https://shrinken.pw/crash-2023-01-19_55-fml.html