Employee
لا يعرف specialField
, ، فقط OtherEmployee
يفعل. تحتاج إلى إلقاءها على الفصل الصحيح للاستخدام specialField
.
Employee otherEmployee = new OtherEmployee();
هذا لا يعطيك OtherEmployee
لكن Employee
. لتكون قادرا على الاستخدام specialField
افعل شيئًا كهذا:
(otherEmployee as OtherEmployee).specialField = yourValue;