79772125

Date: 2025-09-23 00:28:33
Score: 1.5
Natty:
Report link

I had this issue today myself, and realized that a solution might be possible using Reflection and then instantiating a new BaseClass object and then copying the values from the properties of the SubClass object onto the BaseClass object (in this so called extension method).

I won't post the code that solved this for me, but if you do need the code for the above design, try googling something like 'how do I convert an object from one type to another that have the same properties using reflection".

Reasons:
  • Blacklisted phrase (1): how do I
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: Jeff Moretti