編譯器警告 (層級 3) CS0675
更新:2007 年 11 月
錯誤訊息
用於 sign-extended 運算元的 Bitwise-or 運算子 ; 請先考慮轉型為較小的不帶正負號的型別
編譯器隱含地擴大並正負號擴展了變數,然後在位元的 OR 運算中使用該結果值。這樣可能會造成非預期的行為。
下列範例會產生 CS0675:
// CS0675.cs
// compile with: /W:3
using System;
public class sign
{
public static void Main()
{
int hi = 1;
int lo = 1;
long value = (((long)hi) << 32) | lo; // CS0675
// try the following line instead
// long value = (((long)hi) << 32) | ((uint)lo); // correct
}
}