Converting values between same structure within different namespace. C#

前端 未结 7 1425
情书的邮戳
情书的邮戳 2021-01-13 17:28

I have two similar[all attributes are same.] structures within different namespaces.

Now when i try to copy values between the objects of these structures i am getti

相关标签:
7条回答
  • 2021-01-13 17:51

    From the description in the question it sounds like you want to have implicit conversion between your types. Whilst you may be able to do this, and in addition to the other suggestions, you might be better using other methods like

    • having a class to do the conversion for you
    • adding a constructor to each class to generate a type of A from a type of B and vice versa
    • adding an extension method to each to act as a factory for producing the other
    0 讨论(0)
提交回复
热议问题