获取表示C#中的int的位数组 [英] Get an array of bits that represent an int in c#

查看:314
本文介绍了获取表示C#中的int的位数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以显示c#中int的位表示形式?

Is there a way to show the representation of an int in bits in c#?

1  = 00001
20 = 10100

我尝试使用BitConverter时没有运气.这应该很简单,但是我找不到解决方案!

I have tried using BitConverter with no luck. This should be simple, but I can't find a solution!

推荐答案

转换. ToString(值,基数)

将32位带符号整数的值转换为指定基数的等效字符串表示形式.将基数指定为2.

Convert.ToString(value, base)

Converts the value of a 32-bit signed integer to its equivalent string representation in a specified base. Specify 2 for the base.

这篇关于获取表示C#中的int的位数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆