我正在尝试使用 <<
long
上的运算符(operator),像这样:
((long) num3) << ( 2 + (long) num4)))
这给了我以下错误:
Operator << cannot be applied to operands of type long and long.
如果我不投 num4
到 long
,没有错误。但是,我不能将其保留为 int
.还有其他解决方法吗?
最佳答案
正确的操作数必须是 int
,而不是 long
。使用 long
作为要移动的位数是没有意义的,因为 C# 中的整数类型永远不会超过 64 位。
关于c# - 运算符 << 不能应用于 long 和 long 类型的操作数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26808716/