C#中的赋值运算符是什么?
运算符是一个符号,告诉编译器执行特定的数学或逻辑操作。
以下是C#中的赋值运算符。
示例
using System;
namespace Demo {
class Program {
static void Main(string[] args) {
int a = 21;
int c;
c = a;
Console.WriteLine("Value of c = {0}", c);
c += a;
Console.WriteLine("Value of c = {0}", c);
c -= a;
Console.WriteLine("Value of c = {0}", c);
c *= a;
Console.WriteLine("Value of c = {0}", c);
c /= a;
Console.WriteLine("Value of c = {0}", c);
c = 200;
c %= a;
Console.WriteLine("Value of c = {0}", c);
c <<= 2;
Console.WriteLine("Value of c = {0}", c);
c >>= 2;
Console.WriteLine("Value of c = {0}", c);
c &= 2;
Console.WriteLine("Value of c = {0}", c);
c ^= 2;
Console.WriteLine("Value of c = {0}", c);
c |= 2;
Console.WriteLine("Value of c = {0}", c);
Console.ReadLine();
}
}
}输出结果
Value of c = 21 Value of c = 42 Value of c = 21 Value of c = 441 Value of c = 21 Value of c = 11 Value of c = 44 Value of c = 11 Value of c = 2 Value of c = 0 Value of c = 2
热门推荐
9 怎么说祝福语简短
10 初八祝福语简短语
11 英文祝福语简短带名字
12 新疆新年祝福语大全简短
13 5岁宝宝祝福语简短
14 生日祝福语 简短独特老弟
15 别人过大寿祝福语简短
16 女生 节日祝福语简短大气
17 八十大寿简短祝福语
18 同事离别祝福语简短的