zoukankan      html  css  js  c++  java
  • c#基础知识第二节

    在c#中,运算符可以分为算术运算符、赋值运算符、比较运算符和逻辑运算符。 

     % (取模,求余数)7%5 ;2

     ++(自增)a++;将a的值加1;

     -- (自减)a--;将a的值减1;

     整型相除结果仍为整型,如果除不整,则舍去小数部分。

     表达式由操作数和运算符组成;

     a++的结果等于a没有加1之前的值;

     ++a结果等于a加1之后的值。

     三元运算符

     using System;

     class  program

    {

      static  void  Main()

      {

             int  x =0;

        int  y =1;

        int  max = x > y ? x : y;

        Console.WriteLine(max);

      }

    }

     if条件语句

     using System;

     class  program

    {

      static  void  Main()

      {

        int  x =5;

           if (x < 10)  / / 判断条件

        {

         x = x + 1; / / 执行语句

        }

           Console.WriteLine("x =" +x);

      }

    }

    / / 当+对字符串参与的类型运算时进行连接运算。

     

  • 相关阅读:
    Python成长笔记
    Python成长笔记
    Python成长笔记
    Python成长笔记
    Python成长笔记
    Python成长笔记
    Python成长笔记
    Python成长笔记
    Python成长笔记
    解决Jenkins生成测试报告的问题
  • 原文地址:https://www.cnblogs.com/zhang1997/p/7597445.html
Copyright © 2011-2022 走看看