开发者

Convert a .NET long to an unsigned 8-byte integer

开发者 https://www.devze.com 2022-12-31 20:38 出处:网络
For the purposes of setting a value in Active Dir开发者_如何学JAVAectory I would like to convert a long to an unsigned 8-byte integer, for assignment to an AD property.

For the purposes of setting a value in Active Dir开发者_如何学JAVAectory I would like to convert a long to an unsigned 8-byte integer, for assignment to an AD property.

How can I do this?


A simple cast can cause problems if the long is negative and may result in an OverflowException. You'll need to use the unchecked syntax to ensure it is cast properly.

ulong myUnsignedValue = unchecked( (ulong)originalLongValue );


Cast the long to a ulong.

More info here.

0

精彩评论

暂无评论...
验证码 换一张
取 消