Should IEquatable, IComparable be implemented on non-sealed classes?

I’ve been thinking about this question for a bit and after a bit of consideration I agree that implementing IEquatable<T> and IComparable<T> should only be done on sealed types. I went back and forth for a bit but then I thought of the following test. Under what circumstances should the following ever return false? IMHO, … Read more

Sealed method in C#

Well, you are testing with only two levels of inheritance, and you are not getting to the point that you’re “further overriding” a method. If you make it three, you can see what sealed does: class Base { public virtual void Test() { … } } class Subclass1 : Base { public sealed override void … Read more

What is an internal sealed class in C#?

It is a class that: internal: Can only be accessed from within the assembly it is defined (or friend assemblies). sealed: Cannot be inherited. Marking classes as internal is a way of preventing outside users of an assembly from using them. It’s really a form of design encapsulation and IMHO it is good practice to … Read more

Static and Sealed class differences

This may help you: +————–+—+————————-+——————+———————+ | Class Type | | Can inherit from others | Can be inherited | Can be instantiated | |————–|—|————————-+——————+———————+ | normal | : | YES | YES | YES | | abstract | : | YES | YES | NO | | sealed | : | YES | NO | … Read more