类型"long"和"long"之间有什么区别?在C ++/CLI和C#中? [英] What is the difference between type "long" in C++/CLI and C#?
问题描述
在 C ++/CLI 项目中,我有方法 void DoSomething(long x);
.如果我想在用 C#编写的任何单元测试中使用它,则方法参数 x
会显示为类型 int
.
In the C++/CLI project I have the method void DoSomething(long x);
. If I want to use it in any unit-test written in C#, the method parameter x
shows up as type int
.
为什么我必须在单元测试(C#)中将签名更改为 void DoSomething(long long x);
并将其与类型为 long
的参数一起使用?
Why do I have to change the signature to void DoSomething(long long x);
to use it with parameters of type long
in my unit-tests (C#)?
推荐答案
在C#中, long
是64位数据类型.在C ++中,我们对 long
所了解的全部是,它必须容纳的内容与 int
一样多或更多,并且至少为32位.如果您在c ++中使用 long long
,保证至少64位,它将与C#中的内容匹配.
In C# long
is a 64 bit data type. In C++ All we know about long
is that it has to hold as much or more than an int
and it is at least 32 bits. If you use a long long
in c++ that is guaranteed to be at least 64 bits which will match what you have in C#.
这篇关于类型"long"和"long"之间有什么区别?在C ++/CLI和C#中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!