Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试转换Uint16为UInt32. 如何将UInt16值转换为UInt32C#?
Uint16
UInt32
UInt16
您不必转换它,UInt32可以容纳UInt16所以只需简单地分配它。
UInt16 number = 20; UInt32 newNumber = number; Console.WriteLine("Number: {0}, New Number: {1}",number,newNumber);
输出:
Number: 20, New Number: 20
隐式转换允许从大范围转换为小范围。只需将 UInt16 分配给 UInt32。