Skip to main content

Timeline for downcast and upcast

Current License: CC BY-SA 3.0

12 events
when toggle format what by license comment
S Feb 7, 2018 at 17:39 history suggested v.slobodzian CC BY-SA 3.0
slightly changed the formatting, highlighting the syntax
Feb 7, 2018 at 16:08 review Suggested edits
S Feb 7, 2018 at 17:39
May 11, 2013 at 4:35 comment added Antony Your first statement ("...casting [an instance of Manager class] into an "employee" object [..] means you cannot access anything manager specific") is not completely accurate. In OP's example, if Employee has a virtual member that is overridden in Manager, the CLR will call the Manager implementation, notwithstanding the cast. From the MSDN article on polymorphism in C#: "When a derived class overrides a virtual member, that member is called even when an instance of that class is being accessed as an instance of the base class." The example provided by MSDN is almost identical.
S Feb 13, 2013 at 21:00 history edited ib. CC BY-SA 3.0
Fixed up a mis-named variable
S Feb 13, 2013 at 21:00 history suggested Paul Prewett CC BY-SA 3.0
Fixed up a mis-named variable
Feb 13, 2013 at 20:49 review Suggested edits
Feb 13, 2013 at 21:00
Oct 6, 2009 at 8:25 vote accept user184805
Oct 6, 2009 at 8:20 comment added RCIX I stand corrected on the first point, and i changed the second half of my answer to show both ways of doing it.
Oct 6, 2009 at 8:18 history edited RCIX CC BY-SA 2.5
added 162 characters in body; added 2 characters in body
Oct 6, 2009 at 8:17 comment added Konrad Rudolph Avoid redefining well-established terms: “boxing”, in the context of OOP and C#, means something rather different (= wrapping a value type object into a reference). Also, your example could (and should) use the as operator instead of is, followed by a cast.
Oct 6, 2009 at 8:11 comment added user184805 I need example to know what is Downcasting ?
Oct 6, 2009 at 8:09 history answered RCIX CC BY-SA 2.5