#, You can only cast it if a is actually an instance of Derived. Convert base class to derived class [duplicate]. rev2023.3.3.43278. You cannot cast a base class to a derived class, but you can do the opposite: cast a derived class to a base class. Downcasting makes sense, if you have an Object of derived class but its referenced by a reference of base class type and for some reason You want it back to be referenced by a derived class type reference. You can loop over all members and apply logging to them all. instance of a derived class. No it is not possible. The only way that is possible is static void Main(string[] args) MyBaseClass mybc = You'll need to create a constructor, like you mentioned, or some other conversion method. Chris Capon
Bayfield County, Wi Accident Reports,
Center City Club Wells Fargo Entrance,
Walter Payton Man Of The Year 2022,
Why Won't Music Magpie Accept My Dvds,
Nicknames For Erin,
Articles C