Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C#

-: practical reference

-: practical reference: - subtracts numbers, negates a unary operand, or computes differences for supported time types.

Version: C# operator reference; verified against C# 14

Syntax

left - right
  • subtracts numbers, negates a unary operand, or computes differences for supported time types.

Use it with a type that preserves the required range and units.

Integer overflow and floating-point cancellation can distort the result.

Negating signed MinValue overflows in checked context, and a date difference can exceed its range.

The complete program actually uses -; its exact expected stdout is 5.

Examples

using System;
using System.Linq;
using System.Threading.Tasks;

Console.WriteLine(9 - 4);

Result

5

The complete program actually uses `-`; its exact expected stdout is `5`.

Sources