These operators are the conditional logical AND ( &) and OR ( ||) operators, the null-coalescing operators ? and ?=, the null-conditional operators ?. That is, the value of the leftmost operand of such an operator defines if (or which) other operands should be evaluated. However, some operators evaluate operands conditionally. Typically, all operator operands are evaluated. The following examples demonstrate the order in which operators and operands are evaluated: Expression Unrelated to operator precedence and associativity, operands in an expression are evaluated from left to right. Var message = $"The area of a circle with radius ") // output: a = 1, b = 6 Interpolated string expressions that provide convenient syntax to create formatted strings: var r = 2.3 Here are some other kinds of expressions that C# provides: It can be used only as a statement, as the following example shows: Console.WriteLine("Hello, world!") A void method call is an example of an expression that doesn't produce a result. Typically, an expression produces a result and can be included in another expression. In the following code, examples of expressions are at the right-hand side of assignments: int a, b, c You can use parentheses to change the order of evaluation imposed by operator precedence and associativity. Operator precedence and associativity determine the order in which the operations in an expression are performed. You can combine them into complex expressions by using operators. The simplest C# expressions are literals (for example, integer and real numbers) and names of variables. Typically, you can overload those operators, that is, specify the operator behavior for the operands of a user-defined type. Equality operators that check if their operands are equal or not.Bitwise and shift operators that perform bitwise or shift operations with operands of the integral types.Boolean logical operators that perform logical operations with bool operands.Comparison operators that compare numeric operands.Arithmetic operators that perform arithmetic operations with numeric operands.Those operators include the following groups: Many of them are supported by the built-in types and allow you to perform basic operations with values of those types.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |