Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize binary conversion in C #

Shulou Source: shulou.com Published: 2022-05-31 18:16:01 09月21日 Update

Today, the editor will share with you the relevant knowledge points about how to achieve binary conversion in C#. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article, let's take a look at it.

Conversion between decimal integers and other binary strings.

Hexadecimal in c # is denoted by the prefix 0x.

Int c = 0x1000

First, you can use Convert.ToString (number, baseValue) to convert decimal integers into other binary strings.

When used together, the conversion between arbitrary binary systems can be realized.

1. Decimal integer to binary string Convert.ToString (69, 2) 2, decimal to octal string Convert.ToString (69, 8) 3, decimal to hexadecimal string Convert.ToString (69, 16) / or 69.ToString ("X2") / / or: String.Format ("{0X}, 69") 2. Use Convert.ToInt32/ToByte (strNumber, baseValue) to convert other strings into decimal integers 1. Binary string to decimal integer Convert.ToInt32 ("100111101", 2) 2, octal string to decimal Convert.ToInt32 ("76", 8) 3, hexadecimal string to decimal Convert.ToInt32 ("FFFF", 16) / or int.Parse ("FF", NumberStyles.HexNumber) Convert.ToByte ("FF", 16) / / or byte.Parse ("FF") NumberStyles.HexNumber) these are all the contents of the article "how to achieve binary conversion in C #" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Tags: Decimal character string decimal decimal integer knowledge article hexadecimal clocked between binary octal content different large prefix most that is more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi vpn MySQL Shulou Technology Linux