如何在C Sharp中操纵二进制数? [英] how to manipulate the binary numbers in c sharp ?

查看:151
本文介绍了如何在C Sharp中操纵二进制数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

操纵像doin右移或或"或或"运算n的方法最终显示出来.您能告诉一个程序吗?

Manipulate means like doin right shift or AND or OR operation n finally to display it .Can u please tell one program .

推荐答案

Right shift: >>
Left Shift:  <<
AND:         &
OR:          |
XOR:         ^


一个非常简单的Google会找到您的.请参阅 MSDN运营商 [

在最终分析中,所有数字都是二进制数字-上面的所有方法在byte,int和long数据类型上都可以正常工作.
如果yopu试图在C#代码中以二进制形式指定数字,则您不能:C#语言规范仅允许使用十进制和十六进制数字.十六进制是输入它们的常规方法:


A very simple Google would have found you this. See MSDN Operators[^]

In future, please try to do at least basic research yourself, and not waste your time or ours.



"May i know how to declare this binary num also"

All numbers are binary numbers in the final analysis - all of the above work fine on byte, int and long datatypes.
If yopu are trying to specify a number in binary in your C# code, then you can''t: the C# language specification only allows Decimal and Hexadecimal numbers. Hex is the normal way to enter them:

int i = 0x5F;

如果等效于

if the equivalent of

int i = 95;

或(如果有效)在C#中,它不是)

or (if it worked in C#, which it doesn''t)

int i = 0b1011111;


这篇关于如何在C Sharp中操纵二进制数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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