private static void LSP() { WriteHeading("LSP"); WidgetBase widget = new NotLspWidget(); WidgetBase[] widgetRelatives = widget.Relatives(); try { //try to put some other WidgetBase to the array widgetRelatives[0] = new LspWidget(); } catch (ArrayTypeMismatchException) { Console.WriteLine("ArrayTypeMismatchException handled"); } WidgetBase w = new LspWidget(); WidgetBase[] relatives = w.Relatives(); //try to put some other WidgetBase to the array relatives[0] = new NotLspWidget(); }
public void LspCovariance_Works() { WidgetBase w = new LspWidget(); WidgetBase[] relatives = w.Relatives(); //try to put some other WidgetBase to the array relatives[0] = new NotLspWidget(); Assert.IsTrue(true); }