zoukankan      html  css  js  c++  java
  • C#中的运算(移位、异或、与、或)

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Collections;

    namespace ConsoleApplication3
    {
        class Program
        {

            static void Main(string[] args)
            {
                ///<summary>
                /// 移位运算           
                ///</summary>
                int i = 7;
                int j = 2;
                Console.WriteLine(i >> j);   //输出结果为1

                ///<summary>
                /// 异或运算
                ///</summary>
                int x = 5;
                int y = 3;
                y ^= x;   //等价与y=y^x
                Console.WriteLine(y);        ////输出结果为6

                ///<summary>
                /// 或运算           
                ///</summary>
                int i = 7;
                int j = 2;
                Console.WriteLine(i | j);   //输出结果为7

                ///<summary>
                /// 与运算           
                ///</summary>
                int i = 7;
                int j = 2;
                Console.WriteLine(i & j);   //输出结果为2
            }
        }
    }

  • 相关阅读:
    30个在线学习设计与开发的站点
    马云:你的一生到底该往哪个方向走?
    那些争议最大的编程观点
    Python 标识符
    Python 环境搭建
    Python 简介
    PyCharm 使用技巧
    Shell脚本———— /dev/null 2>&1详解
    linux 创建连接命令 ln -s 软链接
    scp命令详解
  • 原文地址:https://www.cnblogs.com/tianguook/p/1717485.html
Copyright © 2011-2022 走看看