CKTIS / C#
conditional control flow: praktična referenca
conditional control flow: praktična referenca: Pogoji izberejo pot prek if, switch, vzorcev in logičnih operatorjev.
Različica: C# language and .NET 10 reference runtime
Sintaksa
// conditionsPogoji izberejo pot prek if, switch, vzorcev in logičnih operatorjev.
Pogoje oblikujte pozitivno in zapletena pravila izločite v poimenovane funkcije.
Vrstni red && in || vpliva na short-circuit in stranske učinke.
Null, NaN in meje primerjav zahtevajo ločene primere.
Celoten program dejansko uporabi conditional control flow; natančno pričakovani stdout je pass.
Primeri
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 score = 7; Console.WriteLine(score >= 5 ? "pass" : "fail");
Rezultat
pass
Celoten program dejansko uporabi `conditional control flow`; natančno pričakovani stdout je `pass`.