Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C#

expressions and operators: practical reference

expressions and operators: practical reference: Expressions compute values according to types, precedence, conversions, and operator overloads.

Version: C# language and .NET 10 reference runtime

Syntax

// expressions operators

Expressions compute values according to types, precedence, conversions, and operator overloads.

Use parentheses when intent is not obvious and avoid hidden side effects.

Precedence does not always determine the order of effects; an overloaded operator can run user code.

Overflow, division by zero, and null behavior depend on operand types.

The complete program actually uses expressions and operators; its exact expected stdout is 14.

Examples

using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;

var result = 2 + 3 * 4; Console.WriteLine(result);

Result

14

The complete program actually uses `expressions and operators`; its exact expected stdout is `14`.

Sources