当前位置:K88软件开发文章中心编程语言.NET.NET02 → 文章内容

VB.Net - 运算符

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-15 15:58:54

值表如下:pqp&Qp | qp ^ Q00000010111111010011假设A = 60; 和B = 13; 现在的二进制格式,他们将如下: A = 0011 1100 B = 0000 1101 ----------------- A&B = 0000 1100 A | B = 0011 1101 A ^ B = 0011 0001 ?A = 1100 0011 我们已经看到VB.Net支持的Bitwise运算符是And,Or,Xor和Not。 位移位算子分别是用于左移和右移的>>和<<。假设变量A保持60,变量B保持13,则: 显示示例运算符描述示例AndBitwise AND Operator copies a bit to the result if it exists in both operands.如果两个操作数都存在,则按位AND运算符将一个位复制到结果。(A AND B) will give 12, which is 0000 1100OrBinary OR Operator copies a bit if it exists in either operand.二进制OR运算符复制一个位,如果它存在于任一操作数。(A Or B) will give 61, which is 0011 1101XorBinary XOR Operator copies the bit if it is set in one operand but not both.二进制XOR运算符复制该位,如果它在一个操作数中设置,但不是两个操作数。(A Xor B) will give 49, which is 0011 0001NotBinary Ones Complement Operator is unary and has the effect of 'flipping' bits.二进制补码运算符是一元的,具有“翻转”位的效果。(Not A ) will give -61, which is 1100 0011 in 2's complement form due to a signed binary number.<<Binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand.二进制左移位运算符。 左操作数值向左移动由右操作数指定的位数。A << 2 will give 240, which is 1111 0000>>Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand.二进制右移运算符。 左操作数值向右移动由右操作数指定的位数。A >> 2 will give 15, which is 0000 1111赋值运算符VB.Net支持以下赋值运算符: 显示示例 运算符描述例=Simple assignment operator, Assigns values from right side operands to left side operand简单赋值操作符,将值从右侧操作数分配给左侧操作数C = A + B A + B将赋值为C+ =Add AND assignment operator, It adds right operand to the left operand and assigns the result to left operand添加AND赋值运算符,向左操作数添加右操作数,并将结果赋值给左操作数C + = A等于C = C + A- =Subtract AND assignment operator, It subtracts right operand from the left operand and assigns the result to left operand减法AND赋值运算符,它从左操作数中减去右操作数,并将结果赋值给左操作数? - = A等于C = C - 一个* =Multiply AND assignment operator, It multiplies right operand with the left operand and assigns the result to left operand乘法AND赋值运算符,它将右操作数与左操作数相乘,并将结果赋值给左操作数C * = A等于C = C * A/ =Divide AND assignment operator, It divides left operand with the right operand and assigns the result to left operand (floating point division)除法AND赋值运算符,它用右操作数划分左操作数,并将结果分配给左操作数(浮点除法)C / = A等于C = C / A\ =Divide AND assignment operator, It divides left operand with the right operand and assigns the result to left operand (Integer division)除法AND赋值运算符,它用右操作数划分左操作数,并将结果分配给左操作数(整数除法)? = A等于C = C A^ =Exponentiation and assignment operator. It raises the left operand to the power of the right operand and assigns the result to left operand.指数和赋值运算符。 它将左操作数提升为右操作数的幂,并将结果分配给左操作数。C ^ = A等于C = C ^ A<< =Left shift AND assignment operator左移AND赋值运算符C语言的<< = 2是同C = C << 2>> =Right shift AND assignment operator右移AND赋值运算符C >> = 2 >> 2同C = C&=Concatenates a String expression to a String variable or property and assigns the result to the variable or property.将String表达式连接到String变量或属性,并将结果分配给变量或属性。 STR1&= STR2赛车是一样的 STR1 = STR1与STR2 其他运算符有很少其他重要的操作系统支持VB.Net。 显示示例 运算符描述例AddressOfReturns the address of a procedure.返回过程的地址。AddHandler Button1.Click,AddressOf Button1_ClickAwaitIt is applied to an operand in an asynchronous method or lambda expression to suspend execution of the method until the awaited task completes.它应用于异步方法或lambda表达式中的操作数,以暂停该方法的执行,直到等待的任务完成。 Dim result As res= Await AsyncMethodThatReturnsResult()Await AsyncMethod()GetTypeIt returns a Type object for the specified type. The Type object provides information about the type such as its properties, methods, and events.它返回指定类型的Type对象。 Type对象提供有关类型的信息,例如其属性,方法和事件。MsgBox(GetType(Integer).ToString())Function ExpressionIt declares the parameters and code that define a function lambda expression.它声明定义函数lambda表达式的参数和代码。Dim add5 = Function(num As Integer) num + 5'prints 10Console.WriteLine(add5(5))IfIt uses short-circuit evaluation to conditionally return one of two values. The If operator can be called with three arguments or with two arguments.它使用短路评估有条件地返回两个值之一。 可以使用三个参数或两个参数调用If运算符。Dim num = 5Console.WriteLine(If(num >= 0,"Positive", "Negative"))VB.Net中的运算符优先级 运算符优先级确定表达式中的术语分组。 这会影响表达式的计算方式。 某些运算符比其他运算符具有更高的优先级; 例如,乘法运算符的优先级高于加法运算符:例如,x = 7 + 3 * 2; 这里,x被分配13,而不是20,因为operator *具有比+高的优先级,所以

上一页  [1] [2] [3]  下一页


VB.Net - 运算符