In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is a detailed introduction to "how to use C#operator". The content is detailed, the steps are clear, and the details are properly handled. I hope this article "how to use C#operator" can help you solve your doubts. Let's go deeper and learn new knowledge together with the ideas of Xiaobian.
I. Constant
A variable is one whose value can change during program execution. Constants, on the other hand, are constants whose values cannot be changed during program execution.
Definition of constants
Constants are defined by the const keyword. The syntax for defining a constant is as follows:
const ;//example const int num;const char word;num = 233;word = 'c';const string str = "hahahaha! ";const float f = 3.22f
Constants and variables are similar in that you can define the data type of a constant (variable) first and then assign it a value. You can also assign values directly when defining data types.
The difference is that after the first assignment, if you want to change the variable value later, you can directly assign the desired value by using the = assignment operator. Constants, however, cannot be assigned repeatedly after the first assignment.
II. Operators
C#has many rich built-in operators, such as:
(1) Arithmetic operators
(2) Relational operators
(3) Logical operators
(4) bit operator
(5) Assignment operator
(6) Other operators
1. Arithmetic operators
Arithmetic operators, as the name implies, are operators used to perform arithmetic calculations.
int a = 123; int b = 26; int c;//addition c = a + b; // 149//subtraction c = a - b; // 97//multiplication c = a * b; // 3198//division c = a / b; // 4//remainder c = a % b; // 19//self increment c = ++a; // c=124;a=124//self decrement c = a--; // c=123;a=122
(1) If two different data types are computed, you need to consider whether the conversion between the data types is explicit or implicit.
(2) In the above program, if two integer values (a and b) are divided, then c, whether integer or floating point, will only be an integer. This point can be imagined as an integer divided by two numbers.
(3) There are two ways to express self-increase and self-decrease respectively.
c=a++/c=a-or c=++a/c=-a
These two expressions mean different things. The former is to assign the value of a to c first, and then add and subtract a; the latter is to add and subtract a first, and the value of a after the operation is assigned to variable c.
2. Relational operators
An operator that compares two values or two expressions in relation. It is often used in conditional statements. The value obtained after comparison must be of type Boolean, either True or False.
int a = 31;int b = 13;bool c;//equal ==c == a==b; // false//unequal!= c = a!= b; // true//greater than> && greater than =c = a>b; // truec = a>=b; // true//less than < && lesser than =
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.