如何使用C#将变量存储在机器寄存器中? [英] How to let the variable be stored in a machine register using C#?
本文介绍了如何使用C#将变量存储在机器寄存器中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在MSDN上引用并找到了register关键字,但它只在C ++中。
语法:
I had referenced at MSDN and found the register keyword, but it's only in C++.
Syntax:
register int x = 0;
你能用C#告诉我怎么做吗?
谢谢!
Can you tell me how to do that with C#?
Thanks!
推荐答案
你不要t。
即使在C ++中,寄存器
关键字也只是一个建议。编译器可以自由忽略它。
http://stackoverflow.com/ questions / 3207018 / register-keyword-in-c [ ^ ]
在C#中,你没有编译机器代码;你正在编译MSIL。 JIT编译器稍后将MSIL编译为机器代码,应用各种优化以使您的代码在当前硬件上运行得更快。将注册
提示添加到C#变量将完全没有意义。
You don't.
Even in C++, theregister
keyword is only a suggestion. The compiler is free to ignore it.
http://stackoverflow.com/questions/3207018/register-keyword-in-c[^]
In C#, you're not compiling to machine code; you're compiling to MSIL. The JIT compiler later compiles the MSIL to machine code, applying various optimizations to make your code run faster on the current hardware. Adding theregister
hint to a C# variable would be entirely pointless.
这篇关于如何使用C#将变量存储在机器寄存器中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文