- Home /
Question about classes on C#
Hi everyone, This is probably a stupid question, but I just switched from JS to C# a few days back and I have a doubt about how classes work.
If I have a class MyClass : Monobehaviour, and a class Myclass1 : MyClass, does my class MyClass1 inherit all the methods from Monobehaviour as well? And what about if I declare one more class but this time MyClass2 : MyClass1 ? does it still inherits the public methods?
Thank you very much!
Answer by DaveA · Nov 20, 2012 at 10:57 PM
Yes, they inherit all their ancestor (base classes) methods and variables. Unless those ancestors have marked things as 'sealed'
http://msdn.microsoft.com/en-us/library/ms173149.aspx
So MyClass has all of MonoBehaviour, MyClass one has all of MyClass and MonoBehaviour, MyClass2 has all of MyClass1, MyClass, and MonoBehaviour etc.
Your answer
Follow this Question
Related Questions
Making a static class derive from MonoBehaviour in C# 3 Answers
Classes, MonoBehaviours C# 2 Answers
Access to a variable inside a C# class 2 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers