How to convert one type to another using reflection?

前端 未结 3 1490
臣服心动
臣服心动 2021-01-25 03:29

I have a two types that are very similar (i.e. the member names are very similar).

Is there an elegant way to copy one type to another, without having to copy each indi

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-25 04:23

    Maybe Automapper?

    For example:

    Mapper.CreateMap();
    return Mapper.Map(fromCsvFile);
    

提交回复
热议问题