当前位置:网站首页>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#运算符了,所以我要分享给你们,希望可以帮助到你们。
以上就是我的分享,新手上道,请多多指教。如果有更好的方法或不懂得地方欢迎在评论区教导和提问喔!
边栏推荐
- Initial JDBC programming
- spfa AcWing 851. spfa求最短路
- Leetcode - < dynamic planning special> Jianzhi offer 19, 49, 60
- Performance tuning project case
- Heap (priority queue)
- LeetCode—<动态规划专项>剑指 Offer 19、49、60
- The differences and relationships among port, targetport, nodeport and containerport in kubenetes
- [old horse of industrial control] detailed explanation of Siemens PLC TCP protocol
- [ybtoj advanced training guidance] judgment overflow [error]
- Sweetheart leader: Wang Xinling
猜你喜欢
SparkContext: Error initializing SparkContext解决方法
BOM DOM
MySQL与PostgreSQL抓取慢sql的方法
BOM DOM
线性DP AcWing 896. 最长上升子序列 II
Docker compose configuration mysql, redis, mongodb
线性DP AcWing 895. 最长上升子序列
High performance erasure code coding
Win10 system OmniPeek wireless packet capturing network card driver failed to install due to digital signature problem solution
Docker-compose配置Mysql,Redis,MongoDB
随机推荐
哈希表 AcWing 841. 字符串哈希
Drools executes string rules or executes a rule file
The differences and relationships among port, targetport, nodeport and containerport in kubenetes
Lekao: 22 year first-class fire engineer "technical practice" knowledge points
Window10 upgrade encountered a big hole error code: 0xc000000e perfect solution
线性DP AcWing 902. 最短编辑距离
CV2 in OpenCV VideoWriter_ Fourcc() function and cv2 Combined use of videowriter() function
哈希表 AcWing 840. 模拟散列表
Redis bloom filter
Interview with meituan, a 34 year old programmer, was rejected: only those under the age of 30 who work hard and earn little overtime
LeetCode—剑指 Offer 51. 数组中的逆序对
ASP. Net MVC default configuration, if any, jumps to the corresponding program in the specified area
spfa AcWing 851. spfa求最短路
线性DP AcWing 899. 编辑距离
软件测试面试题-2022年大厂面试题合集
Record the range of data that MySQL update will lock
What is the relationship between NFT and metauniverse? How to view the market? The future market trend of NFT
Adding database driver to sqoop of cdh6
计数类DP AcWing 900. 整数划分
单指令多数据SIMD的SSE/AVX指令集和API