c# - How can I get an instance of a base class from an inherited class dynamically? -


I have a class public class fiber: fou

FO has its properties and such foobers I have made an example of Fobre and have set all the properties including base classes. Now I need a frequency of Fauau which is the value of the property which is in FOB. True, I can create a new example and write a code that will populate this new instance with a new experience, but that means that I have to change the properties of the base class every time.

I want

Faw test = (FO) FB;

This "works" in C #, but the test is actually typing.

For ideas

I want to return to an example of a base class which is populated by data / example.

Thoughts?

I dynamically put a reflection to copy the base class' field, found it here: Now I have a true fou type that I can pass to EF.

  Private Fate Getbizadeata (Fobar FB) {Fu test_fou = New Faw (); Type type = FB.GetType (); Type = type. Base type; UpdateForType (type, FB, test_fou); Return exam_fau; } Private static void UpdateForType (type type, foubar source, fou destination) {FieldInfo [] myObjectFields = type.GetFields (BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); Foreign exchange (FieldInfo fi in myObjectFields) {fi.SetValue (destination, fi.GetValue (source)); }}  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -