public static class MyExtensions { public static void NewMethod(this MyClass obj) { // Implementation code goes here } } // Usage: var obj = new MyClass(); obj.NewMethod();
public interface IAdditionalBehavior { void Method3(); } public class MyDerivedClass : MyBaseClass, IAdditionalBehavior { // Implementation of IAdditionalBehavior method goes here public void Method3() { } } // Usage: var obj = new MyDerivedClass(); obj.Method3();
public class MyNewClass : MyBaseClass { public int NewProperty { get; set; } } // Usage: var obj = new MyNewClass(); obj.NewProperty = 10;
public class MyControl : Control { public event EventHandler CustomEvent; protected virtual void OnCustomEvent() { CustomEvent?.Invoke(this, EventArgs.Empty); } } // Usage: var obj = new MyControl(); obj.CustomEvent += (sender, e) => { /* Event handler code goes here */ };Package/library: System.Windows.Forms.