当前位置:网站首页>C#运算符
C#运算符
2022-07-02 09:45:00 【A_tuohai】
- C#中的运算符是一种告诉编译器执行特定的数学或逻辑操作的符号,C#有丰富的内置运算符
- 算术运算符主要分为6中运算符,分别是算术运算符、关系运算符、逻辑运算符、位运算符、赋值运算符、三元运算符
- 首先是算术运算符:假设变量A的值为10,变量B的值为20,接下来是所有运算符的运算结果
- 接下来是关系运算符:假设变量A的值为10,变量B的值为20,接下来是关系运算符的运算结果:
- 接下来是逻辑运算符:假设变量A为布尔值true,变量B的布尔值为false,接下来是逻辑运算符的运算结果:
- 接下来是位运算符:位运算符作用于位,并逐位执行操作.&、 | 和 ^ 的真值表 如下所示: 解析: 通常是指将 数值型的值从十进制转换成二进制后的运算,由于是对二进制数进行运算,所以使用 位运算符对操作数进行运算的速度稍快。
- 接下来是赋值运算符:
- 接下来是三元运算符:三元运算符也被称为条件运算符,与后面要学习的 if 条件语句非类似。 在 C# 语言中三元运算符只有一个,具体的语法形式如下。
其中: 布尔表达式:判断条件,它是一个结果为布尔型值的表达式。 表达式 1:如果布尔表达式的值为 True,该三元运算符得到的结果就是表达式 1 的运算结果。 表达式 2:如果布尔表达式的值为 False,该三元运算符得到的结果就是表达式 2 的运算结果。 需要注意的是,在三元运算符中表达式 1 和表达式 2 的结果的数据类型要兼容。
这是我所学到的C#运算符了,所以我要分享给你们,希望可以帮助到你们。
以上就是我的分享,新手上道,请多多指教。如果有更好的方法或不懂得地方欢迎在评论区教导和提问喔!
边栏推荐
- 线性DP AcWing 897. 最长公共子序列
- Use sqoop to export ads layer data to MySQL
- LeetCode—剑指 Offer 37、38
- LeetCode—剑指 Offer 51. 数组中的逆序对
- 分布式机器学习框架与高维实时推荐系统
- 1380. Lucky numbers in the matrix [two-dimensional array, matrix]
- 线性DP AcWing 898. 数字三角形
- Wechat official account payment prompt MCH_ ID parameter format error
- 哈希表 AcWing 841. 字符串哈希
- JS10day(api 阶段性完结,正则表达式简介,自定义属性,过滤敏感词案例,注册模块验证案例)
猜你喜欢
模块化 CommonJS ES Module
MySQL and PostgreSQL methods to grab slow SQL
AI中台技术调研
ArrayList与LinkedList效率的对比
What is the relationship between NFT and metauniverse? How to view the market? The future market trend of NFT
包管理工具
BOM DOM
Go学习笔记—多线程
arcgis js 4. Add pictures to x map
In development, why do you find someone who is paid more than you but doesn't write any code?
随机推荐
[I'm a mound pytorch tutorial] learning notes
Sse/avx instruction set and API of SIMD
JS10day(api 阶段性完结,正则表达式简介,自定义属性,过滤敏感词案例,注册模块验证案例)
spfa AcWing 852. spfa判断负环
Redis sentinel mechanism and configuration
染色法判定二分图 AcWing 860. 染色法判定二分图
Adding database driver to sqoop of cdh6
BOM DOM
Sub thread get request
Simple use of drools decision table
1380. Lucky numbers in the matrix [two-dimensional array, matrix]
The second composition template of postgraduate entrance examination English / chart composition, English chart composition is enough
Go learning notes - go based interprocess communication
Calculate the maximum path sum of binary tree
LeetCode—<动态规划专项>剑指 Offer 19、49、60
[old horse of industrial control] detailed explanation of Siemens PLC TCP protocol
Leetcode - Sword finger offer 51 Reverse pairs in an array
Interview with meituan, a 34 year old programmer, was rejected: only those under the age of 30 who work hard and earn little overtime
Deep copy event bus
模块化 CommonJS ES Module