开发者

Convert Int64 to binary and back?

开发者 https://www.devze.com 2023-02-08 03:14 出处:网络
Is there a way to convert Int64 to 开发者_StackOverflowbinary and back to Int64?var bytes = BitConverter.GetBytes(long);

Is there a way to convert Int64 to 开发者_StackOverflowbinary and back to Int64?


var bytes = BitConverter.GetBytes(long);
var value = BitConverter.ToInt64(bytes, 0);


if string formatting is what you need:

Convert.ToString(someInt64, 2);
Convert.ToUInt64("101010", 2);


Similar to HuBeZa's answer, this converts type long to string:

Convert.ToString(Convert.ToInt64(myLongInt), 2);
0

精彩评论

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