MyClass in VB.Net
vb.net
Solution
`MyClass`, from a compiler's perspective, is a way to omit a `callvirt` instruction in favor of a `call` instruction. Essentially when you call a method with the virtual semantics (`callvirt`), you're indicating that you want to use the most derived variation. In cases where you wish to omit the derived variations you utilize `MyClass` (`call`). While you've stated you understand the basic concept, I figured it might help to describe it from a functional viewpoint, rather than an implicit understanding. It's functionally identical to `MyBase` with the caveat of scope being base type with `MyBase`, instead of the active type with `MyClass`.
Overriding virtual call semantics, at the current point in the hierarchy, is typically a bad design choice, the only times it is valid is when you must rely on a specific piece of functionality within your object's hierarchy, and can't rely on the inheritor to call your variation through a base invocation in their implementation. It could also rely on you as a designer deciding that it's the only alternative since you overrode the functionality further in the object hierarchy and you must ensure that in this corner case that this specific method, at the current level of the inheritance tree, must be called.
It's all about design, understanding the overall design and corner cases. There's likely a reason C♯ doesn't include such functionality since on those corner cases you could separate the method into a private variation the current level in the hierarchy invokes, and just refer to that private implementation when necessary. It's my personal view that utilizing the segmentation approach is the ideal means to an end since it's explicit about your design choice, and is easier to follow (and it's also the only valid means in languages without a functional equivalent to `MyClass`.)
Problem
What is a realistic use for VB.Net's MyClass keyword? I understand the technical usage of MyClass; I don't understand the practical usage of it in the real world. Using MyClass only makes sense if you have any virtual (overridable) members. But it also means that you want to ignore the overridden implementations in sub classes. It appears to be self-contradicting. I can think of some contrived examples, but they are simply bad design rather than practical usage.