CKTIS / C#
System.TimeSpan: praktická referencia
System.TimeSpan: praktická referencia: TimeSpan predstavuje trvanie ako počet tickov, nie dátum alebo časové pásmo.
Verzia: .NET API; verified against .NET 10 reference surface
Syntax
System.TimeSpan /* select a documented member or constructor */TimeSpan predstavuje trvanie ako počet tickov, nie dátum alebo časové pásmo.
Použite na timeouty a časové rozdiely v podporovanom rozsahu.
Hours a Minutes sú zložky; pre celkovú hodnotu použite TotalHours alebo TotalMinutes.
Operácie mimo rozsahu vyhodia OverflowException; parsovanie závisí od formátu a kultúry.
Úplný program skutočne používa System.TimeSpan; presne očakávaný stdout je 1.5.
Prí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ýsledok
1.5
Úplný program skutočne používa `System.TimeSpan`; presne očakávaný stdout je `1.5`.