.net - How to prove there is no multiple inheritance in C#? -
yes asked question , provide, summary of next info knew. ofcourse other getting error when writing so-called expected code, wish write 1, there more valid reasons prove c# doesn't back upwards multiple inheritance?
many questions asked here in , outside web in context of mi of c#, comparing c# java (where java implements mi interfaces), how simulate/emulate mi in c#, how deal lack of mi in c#, what problem mi etc.. question may reflect bits of duplicity questions...however haven't found reply yet, hence thought of shooting.
in blog saw author talking valuable points:
different implementations of mi across languages makes challenge create language-neutral implementation. interfaces can used instead, makes mi bit redundant. mi adds complexity in regards casting, reflection , on.author indicates multiple inheritance of implementation not allowed in c#. so stop leading double diamond inheritance problem/deadly diamond of death.. author had pointed out saying "i have inherited lot both mother , father"..
so makes more sense class inherit multiple super/base/parent classes. e.g. class house inherits class building (the noun, represents details of building{house, school, office, hotel etc}) , class construction (represents details of construction building). great if could,
1. code wish write public class house: building, construction { // methods, properties... } instead have write interface..
interface buildstruction { methodconstruction(); } //class construction has implement interface public class house: building, buildstruction { construction constionobject; methodbuilding(); methodconstruction() { constionobject.methodconstruction(); } } wouldn't had been easier not allow multiple super classes have same name methods (e.g. calculate method)? realize parent/super classes need have freedom create own properties , methods independent of class..
thus mi seems mission impossible in c#...and reasons determined why so.. simply because of,
the diamond problem? and no-body has yet pointed out real utilize of mi in programming?also how does,
mi add together complexity in regardscasting, reflection? interfaces create mi bit redundant? mi cause issues code (full oop supported) language independent? appreciate comment/an reply says more "it's way c# language created..." :)
c# .net interface multiple-inheritance
No comments:
Post a Comment