CKTIS / C#
if: praktická reference
if: praktická reference: if provede větev jen tehdy, když její podmínka bool má hodnotu true.
Verze: C# language; verified against C# 14 reference
Syntaxe
if /* grammar-specific form */if provede větev jen tehdy, když její podmínka bool má hodnotu true.
Použijte pro místní rozhodnutí a složité predikáty přesuňte do pojmenovaných funkcí.
C# nepřevádí čísla ani objekty na bool; short-circuit zůstává v podmínce.
Bez závorek patří k if jen další příkaz; nullable není bool.
Úplný program skutečně používá if; přesně očekávaný stdout je yes.
Příklady
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;
if (2 < 3) Console.WriteLine("yes");
Výsledek
yes
Úplný program skutečně používá `if`; přesně očekávaný stdout je `yes`.