本文介绍了如果有疑问 - 写代码 - 但......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 所以我总是被告知 - 当有疑问时 - 把它写出来然后运行它看看 你自己发生了什么。 但最近有人告诉我,如果我有一个值类型并且我传递它 byref,它将始终打包/取消装箱。我如何找到真相? - Sahil Malik http://dotnetjunkies.com/weblog/sahilmalikSo I have always been told - when in doubt - write it out and run it and seefor yourself what happens.But someone recently told me that if I have a value type and I pass itbyref, it will always box/unbox it. How do I find the truth?- Sahil Malik http://dotnetjunkies.com/weblog/sahilmalik推荐答案 不,将它作为一个对象传递给一个盒子,通过ref传递它或者传递 结果在传递的堆栈地址中(ldloca指令)No, passing it as an object results in a box, passing it via ref or outresults in the stack address being passed(ldloca instruction) 不,将其作为对象传递会产生一个框,通过ref或out传递它会导致堆栈地址被传递(ldloca)指示) No, passing it as an object results in a box, passing it via ref or out results in the stack address being passed(ldloca instruction) 这篇关于如果有疑问 - 写代码 - 但......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-23 20:47