开发者

How do I Convert Integer value to Binary value as a string in C#?

开发者 https://www.devze.com 2023-01-20 13:25 出处:网络
Not sure if I worded the title开发者_如何学Python correctly, so my apologies. I want to simply convert an integer to strings that hold the binary representation of that integer.

Not sure if I worded the title开发者_如何学Python correctly, so my apologies.

I want to simply convert an integer to strings that hold the binary representation of that integer.

Example:

116 would convert to "1110100"

Is there anything built into .Net or will I need to write a small parsing algorithm?


This will do it:

// bin = "1110100"
var bin = Convert.ToString(116, 2)

The second parameter specifies which base to convert to.

0

精彩评论

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