void UseControllingInheritance() { FinalizedObject finalizedObject = new FinalizedObject(); /* │ */ finalizedObject.ExtensionFunction();//←─────────┘ /* ↑ */ /* ┌─────────┴──────────────────────┐ */ /* │function not actually written in│ */ /* │the FinalizedObject class. │ */ /* └────────────────────────────────┘ */ finalizedObject.AnotherExtension(7); // AnotherExtension: 7 AnotherSealedClass another = new AnotherSealedClass(); another.AnotherExtension(3); //SealedFunctions's sealedArg:3 }
public static void AnotherExtension(this AnotherSealedClass anotherClass, int anotherArg) { anotherClass.SealedFunction(anotherArg); }