C#中的按位右移运算符
按位运算符对位进行运算并执行逐位运算。在按位右移运算符中,左操作数的值向右移动右操作数指定的位数。
在下面的代码中,我们有值-
60 i.e. 0011 1100
右移%减号;
c = a >> 2;
右移两次后转换为15-
15 i.e. 0000 1111
示例
您可以尝试运行以下代码以在C#中实现按位右移运算符-
using System;
using System.Collections.Generic;
using System.Text;
namespace Demo {
class toBinary {
static void Main(string[] args) {
int a = 60; /* 60 = 0011 1100 */
int b = 0;
c = a >> 2; /* 15 = 0000 1111 */
Console.WriteLine("Value of b is {0}", b);
Console.ReadLine();
}
}
}热门推荐
1 狗狗技能训练
5 如何训练狗狗笑
6 狗狗训练排便
9 狗狗响片训练
10 如何训练狗狗不捡食
11 狗狗尿训练
12 怎么训练狗狗找东西
13 狗狗训练站立
14 狗狗训练飞盘
15 鞍山狗狗训练
16 怎样训练泰迪狗狗谢谢
17 狗狗外出训练
18 怎么训练金毛狗狗大小便