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 FinalizedObject finalObj, int someArg) { Debug.Log("AnotherExtension: " + someArg); }
public static void ExtensionFunction(this FinalizedObject finalObj) { Debug.Log("Extending the finalizedObject."); }