Step on a token: use the default parameter with caution, and use the parameter with caution.

Source: Internet
Author: User

Step on a token: use the default parameter with caution, and use the parameter with caution.

I always thought. net compiler will compile the default parameters into the reload mode for the main DLL call, until recently want to extend a method does not want to affect the previous call, so added the default parameter. Who knows how to compile and release the DLL where the Method is located and find that the program directly throws an exception that cannot find the Method. After that, I compiled the dll of the main call and found that it can be used again. What is this?

Write a Demo to verify it:

Let's take a look at the running result:

Let's take a look at what IL looks like:

Your sister's original compiler directly calls the default parameter method by assigning the default value to the main DLL, rather than using the overload !!!

So if the method you want to expand has multiple DLL calls, and you do not want to submit so many DLL, You Should reload it yourself and use the default parameter with caution.

 

I am busy playing Dota in the morning. I didn't see that I didn't set the default parameter. It's just a problem. Sweat! Silly

Updated. Thank you for reminding me.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.