Today I learned a lot in the cloud and college, I can only summarize the virtual method and abstract application in C # this time.
Theory:
• Virtual modification is called virtual method• Virtual methods can be overridden by the override keyword in subclasses• Common virtual methods: ToString () Equals
Real:
Defines a people parent class, including Name,gender,age, and a Peohi virtual method that defines two subclass teacher, including year,salary two properties and a Peohi method; subclass student, Includes Stadynum and a Peohi method.
Define subclass Teacher (student subclass is the same as teacher definition method, not described here)
Output in the main function
Output results
Abstract method, define a parent class person, and subclass Chinese
Well, I'll write about it today, and we'll go on with it next time. Come on!
Virtual methods and abstract methods in C # (thirteenth day)