CKTIS / C#
System.TimeSpan: praktická reference
System.TimeSpan: praktická reference: TimeSpan představuje trvání jako počet ticků, nikoli datum nebo časové pásmo.
Verze: .NET API; verified against .NET 10 reference surface
Syntaxe
System.TimeSpan /* select a documented member or constructor */TimeSpan představuje trvání jako počet ticků, nikoli datum nebo časové pásmo.
Použijte pro timeouty a časové rozdíly v podporovaném rozsahu.
Hours a Minutes jsou složky; pro celkovou hodnotu použijte TotalHours nebo TotalMinutes.
Operace mimo rozsah vyhodí OverflowException; parsování závisí na formátu a kultuře.
Úplný program skutečně používá System.TimeSpan; přesně očekávaný stdout je 1.5.
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;
var duration = TimeSpan.FromMinutes(90);
Console.WriteLine(duration.TotalHours.ToString("0.0", CultureInfo.InvariantCulture));
Výsledek
1.5
Úplný program skutečně používá `System.TimeSpan`; přesně očekávaný stdout je `1.5`.