Inside of ChildClass.methodTwo()
, you can call base.methodTwo()
.
Outside of the class, calling ((ParentClass)a).methodTwo()
will call ChildClass.methodTwo
. That’s the whole reason why virtual methods exist.
More Related Contents:
- Why not inherit from List?
- Calling the base constructor in C#
- Get all derived types of a type
- What’s the correct alternative to static method inheritance?
- Implementing IDisposable on a subclass when the parent also implements IDisposable
- C# Covariance on subclass return types
- Can I Override with derived types?
- Why does this polymorphic C# code print what it does?
- What’s the best way to ensure a base class’s static constructor is called?
- Automatically making Base Constructors available in derived class?
- Creating a blocking Queue in .NET?
- Get the correct week number of a given date
- Why doesn’t C# infer my generic types?
- How to get the current user in ASP.NET MVC
- How do I get the title of the current active window using c#?
- Is there any benefit of using an Object Initializer?
- How do you retrieve a list of logged-in/connected users in .NET?
- Can I pass constructor parameters to Unity’s Resolve() method?
- Single-assembly multi-language Windows Forms deployment (ILMerge and satellite assemblies / localization) – possible?
- What is the use of the ArraySegment class?
- Convert string to Brushes/Brush color name in C#
- Remove C# attribute of a property dynamically
- CORS Support within WCF REST Services
- What and when is “using” block used for in C#? How to use “using” block in C#?
- How would I sort a list of files by name to match how Windows Explorer displays them?
- .NET (3.5) formats times using dots instead of colons as TimeSeparator for it-IT culture?
- Reflection.Emit vs CodeDOM
- Why choose a static class over a singleton implementation?
- Upload CSV file to SQL server
- Is int? thread safe?