Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the basic knowledge of C # operator

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what is the basic knowledge of C # operator". The content of the explanation in this article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought. Let's study and learn what the basics of C # operators are.

Basic knowledge of C # operator 1. Arithmetic operator

Arithmetic operators include addition (+), subtraction (-), multiplication (*), division (/), and remainder (%). In addition to the addition and subtraction of integers and real numbers, the addition and subtraction operators also apply to enumerated types, string types, and delegate types, which are achieved through operator replanting.

String mf1= "Mike"; string mf2= "Cat"; string mf3=mf1+mf2;//mf3= "MikeCat" using System; enum Weekday {Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday}; class MikeCat {static void Main () {Weekday mf1=Weekday.Sunday; Weekday mf2=mf1+3; Console.WriteLine ("mf1= {0}, mf2= {1}", mf1,mf2);}} / / result: mf1=Sunday,mf2=Wednesday

Basic knowledge of C # operator 2. Assignment operator

Assignment is to assign a new value to a variable. C # is divided into two categories: simple assignment and compound assignment.

Simple assignment: "=" a=b=c is equivalent to a = (breadc)

Compound assignment: "+ ="-= "* =" / = "% =" | = "^ =" = "axiomatic 10 is equivalent to a=a+10

Basic knowledge of C # operator 3. Comparison operator

The comparison operator is used to compare the size of two expressions, such as greater than (>).

< == != = 。 C# 操作符基础知识4.逻辑操作符 逻辑与(&&) 逻辑或(||) 和 逻辑非(!) C# 操作符基础知识5.位操作符 是对数据按二进制位进行运算的操作符。 c#位操作符包括按位与(&) | ~ >

Using System; class MikeCat {public static void Main () {int astat6; Console.WriteLine ("a = {0}", a); / 6 is 00000110; the binary of / 6 is 00000011, which is equal to 00000010 by bit and after, that is, 2 int bread6 | 3; Console.WriteLine ("b = {0}", b); / 6 is 00000110; the binary of / 6 is 00000011, which equals 00000111 by bit or later, that is, 7 int center6. Console.WriteLine ("c = {0}", c); the binary of / / 6 is 00000110, and the bitwise inverse is 11111001, that is,-7 int d = 6 ^ 3; Console.WriteLine ("d = {0}", d); / 6 is 00000110, and the binary of / 6 is 00000011, which is equal to 00000101 by XOR, that is, 5 int eigen62; Console.WriteLine ("f = {0}", f) The binary system of / / 6 is 00000110, and moving two digits to the right is equal to 00000001, that is, 1}} Thank you for your reading. This is the content of "what are the basics of C # operator?" after the study of this article, I believe you have a deeper understanding of what the basic knowledge of C # operator is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report