How do you explain type forwarding in simple terms?

前端 未结 1 1658
一个人的身影
一个人的身影 2021-01-21 06:36

I am preparing for MCTS 70-536, after reading this article. I am not 100% sure I understand the concept of typeforwarding. I find the steps given in the article even more confus

相关标签:
1条回答
  • 2021-01-21 06:51

    Type forwarding allows you to relocate a type between assemblies. So originally it is TypeA in AssemblyA. By applying type-forwarding, you can end with TypeA in AssemblyB.

    The subtlety is the code that is already compiled doesn't see the change - they ask for the type in AssemblyA, and the runtime silently gives them the type from AssemblyB. This is very important if you have existing code.

    However; new code cannot be recompiled referencing TypeA without you referencing AssemblyB.

    So:

    • old clients don't need to be recompiled
    • however, you do need to rebuild both AssemblyA and AssemblyB in the above example
    • new code (or any recompiled code) must now reference AssemblyB (the new one)
    0 讨论(0)
提交回复
热议问题