c# - 关于位移符号 >> 和 << 的使用

1.前言

这是对二进制数据进行位移的方法

2.操作

using System;

namespace ConsoleApp1.toValue
{
    public class test1
    {
        public static void Main(string[] args)
        {
            /* 60 = 0011 1100 */
            const int a = 60;
            //1111 0000
            const int a2 = a << 2;
            //0011 11
            const int a3 = a >> 2;
            Console.WriteLine(a);
            Console.WriteLine(a2);
            Console.WriteLine(a3);
        }
    }
}

3.控制台打印

 

posted @ 2020-08-28 11:38  岑惜  阅读(909)  评论(0编辑  收藏  举报