TimeSpan TimeSpan TimeSpan TimeSpan Struct

定義

表示時間間隔。Represents a time interval.

public value class TimeSpan : IComparable, IComparable<TimeSpan>, IEquatable<TimeSpan>, IFormattable
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public struct TimeSpan : IComparable, IComparable<TimeSpan>, IEquatable<TimeSpan>, IFormattable
type TimeSpan = struct
    interface IFormattable
Public Structure TimeSpan
Implements IComparable, IComparable(Of TimeSpan), IEquatable(Of TimeSpan), IFormattable
繼承
屬性
實作

範例

下列範例會具現TimeSpan化物件,代表兩個日期之間的差異。The following example instantiates a TimeSpan object that represents the difference between two dates. 然後,它會TimeSpan顯示物件的屬性。It then displays the TimeSpan object's properties.

// Define two dates.
DateTime date1 = new DateTime(2010, 1, 1, 8, 0, 15);
DateTime date2 = new DateTime(2010, 8, 18, 13, 30, 30);

// Calculate the interval between the two dates.
TimeSpan interval = date2 - date1;
Console.WriteLine("{0} - {1} = {2}", date2, date1, interval.ToString());

// Display individual properties of the resulting TimeSpan object.
Console.WriteLine("   {0,-35} {1,20}", "Value of Days Component:", interval.Days);
Console.WriteLine("   {0,-35} {1,20}", "Total Number of Days:", interval.TotalDays);
Console.WriteLine("   {0,-35} {1,20}", "Value of Hours Component:", interval.Hours);
Console.WriteLine("   {0,-35} {1,20}", "Total Number of Hours:", interval.TotalHours);
Console.WriteLine("   {0,-35} {1,20}", "Value of Minutes Component:", interval.Minutes);
Console.WriteLine("   {0,-35} {1,20}", "Total Number of Minutes:", interval.TotalMinutes);
Console.WriteLine("   {0,-35} {1,20:N0}", "Value of Seconds Component:", interval.Seconds);
Console.WriteLine("   {0,-35} {1,20:N0}", "Total Number of Seconds:", interval.TotalSeconds);
Console.WriteLine("   {0,-35} {1,20:N0}", "Value of Milliseconds Component:", interval.Milliseconds);
Console.WriteLine("   {0,-35} {1,20:N0}", "Total Number of Milliseconds:", interval.TotalMilliseconds);
Console.WriteLine("   {0,-35} {1,20:N0}", "Ticks:", interval.Ticks);

// This example displays the following output:
//       8/18/2010 1:30:30 PM - 1/1/2010 8:00:15 AM = 229.05:30:15
//          Value of Days Component:                             229
//          Total Number of Days:                   229.229340277778
//          Value of Hours Component:                              5
//          Total Number of Hours:                  5501.50416666667
//          Value of Minutes Component:                           30
//          Total Number of Minutes:                       330090.25
//          Value of Seconds Component:                           15
//          Total Number of Seconds:                      19,805,415
//          Value of Milliseconds Component:                       0
//          Total Number of Milliseconds:             19,805,415,000
//          Ticks:                               198,054,150,000,000
' Define two dates.
Dim date1 As Date = #1/1/2010 8:00:15AM#
Dim date2 As Date = #8/18/2010 1:30:30PM#
' Calculate the interval between the two dates.
Dim interval As TimeSpan = date2 - date1
Console.WriteLine("{0} - {1} = {2}", date2, date1, interval.ToString())
' Display individual properties of the resulting TimeSpan object.
Console.WriteLine("   {0,-35} {1,20}", "Value of Days Component:", interval.Days)
Console.WriteLine("   {0,-35} {1,20}", "Total Number of Days:", interval.TotalDays)
Console.WriteLine("   {0,-35} {1,20}", "Value of Hours Component:", interval.Hours)
Console.WriteLine("   {0,-35} {1,20}", "Total Number of Hours:", interval.TotalHours)
Console.WriteLine("   {0,-35} {1,20}", "Value of Minutes Component:", interval.Minutes)
Console.WriteLine("   {0,-35} {1,20}", "Total Number of Minutes:", interval.TotalMinutes)
Console.WriteLine("   {0,-35} {1,20:N0}", "Value of Seconds Component:", interval.Seconds)
Console.WriteLine("   {0,-35} {1,20:N0}", "Total Number of Seconds:", interval.TotalSeconds)
Console.WriteLine("   {0,-35} {1,20:N0}", "Value of Milliseconds Component:", interval.Milliseconds)
Console.WriteLine("   {0,-35} {1,20:N0}", "Total Number of Milliseconds:", interval.TotalMilliseconds)
Console.WriteLine("   {0,-35} {1,20:N0}", "Ticks:", interval.Ticks)
' The example displays the following output:
'       8/18/2010 1:30:30 PM - 1/1/2010 8:00:15 AM = 229.05:30:15
'          Value of Days Component:                             229
'          Total Number of Days:                   229.229340277778
'          Value of Hours Component:                              5
'          Total Number of Hours:                  5501.50416666667
'          Value of Minutes Component:                           30
'          Total Number of Minutes:                       330090.25
'          Value of Seconds Component:                           15
'          Total Number of Seconds:                      19,805,415
'          Value of Milliseconds Component:                       0
'          Total Number of Milliseconds:             19,805,415,000
'          Ticks:                               198,054,150,000,000
# Define two dates.
$Date2 = Get-Date -Date '2010/8/18' -Hour 13 -Minute 30 -Second 30
$Date1 = Get-Date -Date '2010/1/1'  -Hour 8  -Minute 0  -Second 15

# Calculate the interval between the two dates.
$Interval = $Date2 - $Date1
"{0} - {1} = {2}" -f $Date2, $Date1, ($Interval.ToString())

#  Display individual properties of the resulting TimeSpan object.
"   {0,-35} {1,20}"    -f "Value of Days Component:", $Interval.Days
"   {0,-35} {1,20}"    -f "Total Number of Days:", $Interval.TotalDays
"   {0,-35} {1,20}"    -f "Value of Hours Component:", $Interval.Hours
"   {0,-35} {1,20}"    -f "Total Number of Hours:", $Interval.TotalHours
"   {0,-35} {1,20}"    -f "Value of Minutes Component:", $Interval.Minutes
"   {0,-35} {1,20}"    -f "Total Number of Minutes:", $Interval.TotalMinutes
"   {0,-35} {1,20:N0}" -f "Value of Seconds Component:", $Interval.Seconds
"   {0,-35} {1,20:N0}" -f "Total Number of Seconds:", $Interval.TotalSeconds
"   {0,-35} {1,20:N0}" -f "Value of Milliseconds Component:", $Interval.Milliseconds
"   {0,-35} {1,20:N0}" -f "Total Number of Milliseconds:", $Interval.TotalMilliseconds
"   {0,-35} {1,20:N0}" -f "Ticks:", $Interval.Ticks

<# This sample produces the following output:

18/08/2010 13:30:30 - 01/01/2010 08:00:15 = 229.05:30:15
   Value of Days Component:                             229
   Total Number of Days:                   229.229340277778
   Value of Hours Component:                              5
   Total Number of Hours:                  5501.50416666667
   Value of Minutes Component:                           30
   Total Number of Minutes:                       330090.25
   Value of Seconds Component:                           15
   Total Number of Seconds:                      19,805,415
   Value of Milliseconds Component:                       0
   Total Number of Milliseconds:             19,805,415,000
   Ticks:                               198,054,150,000,000
#>

備註

TimeSpan物件代表時間間隔(時間或經過時間的持續時間),以正數或負數的天數、小時、分鐘、秒和小數的秒數來測量。A TimeSpan object represents a time interval (duration of time or elapsed time) that is measured as a positive or negative number of days, hours, minutes, seconds, and fractions of a second. TimeSpan結構也可以用來代表當天的時間,但只有在時間與特定日期無關時才會使用。The TimeSpan structure can also be used to represent the time of day, but only if the time is unrelated to a particular date. 否則, DateTime應改用DateTimeOffset或結構。Otherwise, the DateTime or DateTimeOffset structure should be used instead. (如需使用TimeSpan結構來反映當天時間的詳細資訊,請參閱在 DateTime、DateTimeOffset、TimeSpan 和 TimeZoneInfo 之間進行選擇)。(For more information about using the TimeSpan structure to reflect the time of day, see Choosing Between DateTime, DateTimeOffset, TimeSpan, and TimeZoneInfo.)

注意

TimeSpan值代表時間間隔,可以用特定的天數、小時、分鐘、秒和毫秒數表示。A TimeSpan value represents a time interval and can be expressed as a particular number of days, hours, minutes, seconds, and milliseconds. 因為它代表不含特定起點或終點參考的一般間隔,所以無法以年和月為單位來表示,兩者都有可變的天數。Because it represents a general interval without reference to a particular start or end point, it cannot be expressed in terms of years and months, both of which have a variable number of days. 其不同于DateTime值,其代表不含特定時區參考的日期和時間, DateTimeOffset或是代表特定時間點的值。It differs from a DateTime value, which represents a date and time without reference to a particular time zone, or a DateTimeOffset value, which represents a specific moment of time.

TimeSpan結構用來測量 duration 的最大時間單位是一天。The largest unit of time that the TimeSpan structure uses to measure duration is a day. 時間間隔是以天數為單位來測量,因為較大的時間單位數(例如月份和年份)會有所不同。Time intervals are measured in days for consistency, because the number of days in larger units of time, such as months and years, varies.

TimeSpan物件的值是等於所表示之時間間隔的刻度數。The value of a TimeSpan object is the number of ticks that equal the represented time interval. 滴答等於100毫微秒,或 1 10-百萬分之一秒的秒數。A tick is equal to 100 nanoseconds, or one ten-millionth of a second. TimeSpan物件的值範圍可以從TimeSpan.MinValueTimeSpan.MaxValueThe value of a TimeSpan object can range from TimeSpan.MinValue to TimeSpan.MaxValue.

具現化 TimeSpan 值Instantiating a TimeSpan Value

您可以透過數TimeSpan種方式將值具現化:You can instantiate a TimeSpan value in a number of ways:

  • 藉由呼叫其隱含無參數的函式。By calling its implicit parameterless constructor. 這會建立其值為TimeSpan.Zero的物件,如下列範例所示。This creates an object whose value is TimeSpan.Zero, as the following example shows.

    TimeSpan interval = new TimeSpan();
    Console.WriteLine(interval.Equals(TimeSpan.Zero));    // Displays "True".
    
    Dim interval As New TimeSpan()
    Console.WriteLine(interval.Equals(TimeSpan.Zero))     ' Displays "True".
    
  • 藉由呼叫其中一個明確的函式。By calling one of its explicit constructors. 下列範例會將TimeSpan值初始化為指定的小時、分鐘和秒數。The following example initializes a TimeSpan value to a specified number of hours, minutes, and seconds.

    TimeSpan interval = new TimeSpan(2, 14, 18);
    Console.WriteLine(interval.ToString());              
    
    // Displays "02:14:18".
    
    Dim interval As New TimeSpan(2, 14, 18)
    Console.WriteLine(interval.ToString())                ' Displays "02:14:18".
    
  • 藉由呼叫方法或執行會TimeSpan傳回值的作業。By calling a method or performing an operation that returns a TimeSpan value. 例如,您可以將代表兩TimeSpan個日期和時間值之間間隔的值具現化,如下列範例所示。For example, you can instantiate a TimeSpan value that represents the interval between two date and time values, as the following example shows.

    DateTime departure = new DateTime(2010, 6, 12, 18, 32, 0);
    DateTime arrival = new DateTime(2010, 6, 13, 22, 47, 0);
    TimeSpan travelTime = arrival - departure;  
    Console.WriteLine("{0} - {1} = {2}", arrival, departure, travelTime);      
    
    // The example displays the following output:
    //       6/13/2010 10:47:00 PM - 6/12/2010 6:32:00 PM = 1.04:15:00
    
    Dim departure As DateTime = #06/12/2010 6:32PM#
    Dim arrival As DateTime = #06/13/2010 10:47PM#
    Dim travelTime As TimeSpan = arrival - departure  
    Console.WriteLine("{0} - {1} = {2}", arrival, departure, travelTime)      
    ' The example displays the following output:
    '       6/13/2010 10:47:00 PM - 6/12/2010 6:32:00 PM = 1.04:15:00
    

    您也可以使用這TimeSpan種方式將物件初始化為零時間值,如下列範例所示。You can also initialize a TimeSpan object to a zero time value in this way, as the following example shows.

       Random rnd = new Random();
    
       TimeSpan timeSpent = TimeSpan.Zero;
    
       timeSpent += GetTimeBeforeLunch();
       timeSpent += GetTimeAfterLunch();
    
       Console.WriteLine("Total time: {0}", timeSpent);
    
       TimeSpan GetTimeBeforeLunch()
       {
          return new TimeSpan(rnd.Next(3, 6), 0, 0);
       }
       
       TimeSpan GetTimeAfterLunch()
       {
          return new TimeSpan(rnd.Next(3, 6), 0, 0);
       }
    
       // The example displays output like the following:
       //        Total time: 08:00:00
    
    Module Example
       Dim rnd As New Random()
       
       Public Sub Main()
          Dim timeSpent As TimeSpan = TimeSpan.Zero
    
          timeSpent += GetTimeBeforeLunch()
          timeSpent += GetTimeAfterLunch()
    
          Console.WriteLine("Total time: {0}", timeSpent)
       End Sub
       
       Private Function GetTimeBeforeLunch() As TimeSpan
          Return New TimeSpan(rnd.Next(3, 6), 0, 0)
       End Function
       
       Private Function GetTimeAfterLunch() As TimeSpan
          Return New TimeSpan(rnd.Next(3, 6), 0, 0)
       End Function
    End Module
    ' The example displays output like the following:
    '       Total time: 08:00:00
    

    TimeSpan值會由DateTimeDateTimeOffsetTimeSpan結構的算術運算子和方法傳回。TimeSpan values are returned by arithmetic operators and methods of the DateTime, DateTimeOffset, and TimeSpan structures.

  • 藉由剖析TimeSpan值的字串表示。By parsing the string representation of a TimeSpan value. 您可以使用ParseTryParse方法,將包含時間間隔TimeSpan的字串轉換成值。You can use the Parse and TryParse methods to convert strings that contain time intervals to TimeSpan values. 下列範例會使用Parse方法,將TimeSpan字串陣列轉換成值。The following example uses the Parse method to convert an array of strings to TimeSpan values.

    string[] values = { "12", "31.", "5.8:32:16", "12:12:15.95", ".12"};
    foreach (string value in values)
    {
       try {
          TimeSpan ts = TimeSpan.Parse(value);
          Console.WriteLine("'{0}' --> {1}", value, ts);
       }
       catch (FormatException) {
          Console.WriteLine("Unable to parse '{0}'", value);
       }
       catch (OverflowException) {
          Console.WriteLine("'{0}' is outside the range of a TimeSpan.", value);
       }   
    }
    
    // The example displays the following output:
    //       '12' --> 12.00:00:00
    //       Unable to parse '31.'
    //       '5.8:32:16' --> 5.08:32:16
    //       '12:12:15.95' --> 12:12:15.9500000
    //       Unable to parse '.12'  
    
    Dim values() As String = { "12", "31.", "5.8:32:16", "12:12:15.95", ".12"}
    For Each value As String In values
       Try
          Dim ts As TimeSpan = TimeSpan.Parse(value)
          Console.WriteLine("'{0}' --> {1}", value, ts)
       Catch e As FormatException
          Console.WriteLine("Unable to parse '{0}'", value)
       Catch e As OverflowException
          Console.WriteLine("'{0}' is outside the range of a TimeSpan.", value)
       End Try   
    Next
    ' The example displays the following output:
    '       '12' --> 12.00:00:00
    '       Unable to parse '31.'
    '       '5.8:32:16' --> 5.08:32:16
    '       '12:12:15.95' --> 12:12:15.9500000
    '       Unable to parse '.12'  
    

    此外,您可以藉由TimeSpan ParseExact呼叫或TryParseExact方法,定義要剖析並轉換成值的輸入字串精確格式。In addition, you can define the precise format of the input string to be parsed and converted to a TimeSpan value by calling the ParseExact or TryParseExact method.

執行 TimeSpan 值的作業Performing Operations on TimeSpan Values

您可以使用AdditionSubtraction運算子Add ,或藉由呼叫和Subtract方法來加入和減去持續時間。You can add and subtract time durations either by using the Addition and Subtraction operators, or by calling the Add and Subtract methods. 您也可以藉由呼叫CompareCompareToEquals方法來比較兩個持續時間。You can also compare two time durations by calling the Compare, CompareTo, and Equals methods. 結構也Duration包含和Negate方法,其會將時間間隔轉換成正值和負值, TimeSpanThe TimeSpan structure also includes the Duration and Negate methods, which convert time intervals to positive and negative values,

TimeSpan值的MinValue 範圍MaxValue為。The range of TimeSpan values is MinValue to MaxValue.

格式化 TimeSpan 值Formatting a TimeSpan Value

值可以表示為 [-] d。 TimeSpan hhmmssff,其中選擇性的減號表示負的時間間隔, d元件為天, hh是以24小時制測量的小時, mm是分鐘, ss是秒,而ff則是的小數秒鐘.A TimeSpan value can be represented as [-]d.hh:mm:ss.ff, where the optional minus sign indicates a negative time interval, the d component is days, hh is hours as measured on a 24-hour clock, mm is minutes, ss is seconds, and ff is fractions of a second. 也就是說,時間間隔是由不含時間的正數或負數天數,或一天中的某個時間,或只有一天的時間所組成。That is, a time interval consists of a positive or negative number of days without a time of day, or a number of days with a time of day, or only a time of day.

ToString TimeSpan從開始.NET Framework 4.NET Framework 4,結構會透過其方法的多載支援區分文化特性的格式,將值轉換為其字串表示。 TimeSpanBeginning with the .NET Framework 4.NET Framework 4, the TimeSpan structure supports culture-sensitive formatting through the overloads of its ToString method, which converts a TimeSpan value to its string representation. 預設TimeSpan.ToString()方法會使用與舊版 .NET Framework 中的傳回值相同的不變格式,傳回時間間隔。The default TimeSpan.ToString() method returns a time interval by using an invariant format that is identical to its return value in previous versions of the .NET Framework. TimeSpan.ToString(String)多載可讓您指定格式字串,以定義時間間隔的字串表示。The TimeSpan.ToString(String) overload lets you specify a format string that defines the string representation of the time interval. TimeSpan.ToString(String, IFormatProvider)多載可讓您指定格式字串和文化特性,其格式設定慣例會用來建立時間間隔的字串表示。The TimeSpan.ToString(String, IFormatProvider) overload lets you specify a format string and the culture whose formatting conventions are used to create the string representation of the time interval. TimeSpan同時支援標準和自訂格式字串。TimeSpan supports both standard and custom format strings. (如需詳細資訊,請參閱標準 TimeSpan 格式字串自訂 timespan 格式字串。)不過,只有標準格式字串是區分文化特性的。(For more information, see Standard TimeSpan Format Strings and Custom TimeSpan Format Strings.) However, only standard format strings are culture-sensitive.

還原舊版 TimeSpan 格式Restoring Legacy TimeSpan Formatting

在某些情況下,成功格式化TimeSpan和舊版中.NET Framework 3.5.NET Framework 3.5之值的程式碼會在中.NET Framework 4.NET Framework 4失敗。In some cases, code that successfully formats TimeSpan values in .NET Framework 3.5.NET Framework 3.5 and earlier versions fails in .NET Framework 4.NET Framework 4. 這在程式碼中最常見,它會呼叫< 的 TimeSpan_LegacyFormatMode > 元素方法TimeSpan ,以格式字串來格式化值。This is most common in code that calls a <TimeSpan_LegacyFormatMode> element method to format a TimeSpan value with a format string. 下列範例會成功格式化和TimeSpan舊版中.NET Framework 3.5.NET Framework 3.5的值,但在和更新版本中.NET Framework 4.NET Framework 4擲回例外狀況。The following example successfully formats a TimeSpan value in .NET Framework 3.5.NET Framework 3.5 and earlier versions, but throws an exception in .NET Framework 4.NET Framework 4 and later versions. 請注意,它會嘗試使用TimeSpan和舊版中.NET Framework 3.5.NET Framework 3.5忽略的不支援格式規範來格式化值。Note that it attempts to format a TimeSpan value by using an unsupported format specifier, which is ignored in .NET Framework 3.5.NET Framework 3.5 and earlier versions.

ShowFormattingCode();
// Output from .NET Framework 3.5 and earlier versions:
//       12:30:45
// Output from .NET Framework 4:
//       Invalid Format    

Console.WriteLine("---");

ShowParsingCode();
// Output:
//       000000006 --> 6.00:00:00

void ShowFormattingCode()
{
   TimeSpan interval = new TimeSpan(12, 30, 45);
   string output;
   try {
      output = String.Format("{0:r}", interval);
   }
   catch (FormatException) {
      output = "Invalid Format";
   }
   Console.WriteLine(output);
}

void ShowParsingCode()
{
   string value = "000000006";
   try {
      TimeSpan interval = TimeSpan.Parse(value);
      Console.WriteLine("{0} --> {1}", value, interval);
   }
   catch (FormatException) {
      Console.WriteLine("{0}: Bad Format", value);
   }   
   catch (OverflowException) {
      Console.WriteLine("{0}: Overflow", value);
   }
}
Dim interval As New TimeSpan(12, 30, 45)
Dim output As String
Try
   output = String.Format("{0:r}", interval)
Catch e As FormatException
   output = "Invalid Format"
End Try
Console.WriteLine(output)
' Output from .NET Framework 3.5 and earlier versions:
'       12:30:45
' Output from .NET Framework 4:
'       Invalid Format

如果您無法修改程式碼,您可以透過下列其中一種TimeSpan方式來還原值的舊版格式設定:If you cannot modify the code, you can restore the legacy formatting of TimeSpan values in one of the following ways:

  • 藉由建立包含< TimeSpan_LegacyFormatMode > 元素的設定檔。By creating a configuration file that contains the <TimeSpan_LegacyFormatMode> element. 設定這個專案的enabled屬性, true以根據TimeSpan每個應用程式來還原舊版格式。Setting this element's enabled attribute to true restores legacy TimeSpan formatting on a per-application basis.

  • 當您建立應用程式域時,設定 "NetFx40_TimeSpanLegacyFormatMode" 相容性參數。By setting the "NetFx40_TimeSpanLegacyFormatMode" compatibility switch when you create an application domain. 這可讓TimeSpan您以每個應用程式網域為基礎來進行舊版格式設定。This enables legacy TimeSpan formatting on a per-application-domain basis. 下列範例會建立使用舊版TimeSpan格式的應用程式域。The following example creates an application domain that uses legacy TimeSpan formatting.

    using System;
    
    public class Example
    {
       public static void Main()
       {
          AppDomainSetup appSetup = new AppDomainSetup();
          appSetup.SetCompatibilitySwitches( new string[] { "NetFx40_TimeSpanLegacyFormatMode" } );
          AppDomain legacyDomain = AppDomain.CreateDomain("legacyDomain", 
                                                          null, appSetup);
          legacyDomain.ExecuteAssembly("ShowTimeSpan.exe");
       }
    }
    
    Module Example
       Public Sub Main()
          Dim appSetup As New AppDomainSetup()
          appSetup.SetCompatibilitySwitches( { "NetFx40_TimeSpanLegacyFormatMode" } )
          Dim legacyDomain As AppDomain = AppDomain.CreateDomain("legacyDomain", 
                                                                 Nothing, appSetup)
          legacyDomain.ExecuteAssembly("ShowTimeSpan.exe")
       End Sub
    End Module
    

    當下列程式碼在新的應用程式域中執行時,它TimeSpan會還原成舊版格式設定行為。When the following code executes in the new application domain, it reverts to legacy TimeSpan formatting behavior.

    using System;
    
    public class Example
    {
       public static void Main()
       {
          TimeSpan interval = DateTime.Now - DateTime.Now.Date;
          string msg = String.Format("Elapsed Time Today: {0:d} hours.",
                                     interval);
          Console.WriteLine(msg);
       }
    }
    // The example displays the following output:
    //       Elapsed Time Today: 01:40:52.2524662 hours.
    
    Module Example
       Public Sub Main()
          Dim interval As TimeSpan = Date.Now - Date.Now.Date
          Dim msg As String = String.Format("Elapsed Time Today: {0:d} hours.",
                                             interval)
          Console.WriteLine(msg)
       End Sub
    End Module
    ' The example displays output like the following:
    '       Elapsed Time Today: 01:40:52.2524662 hours.
    

建構函式

TimeSpan(Int64) TimeSpan(Int64) TimeSpan(Int64) TimeSpan(Int64)

TimeSpan 結構的新執行個體初始化為刻度的指定數目。Initializes a new instance of the TimeSpan structure to the specified number of ticks.

TimeSpan(Int32, Int32, Int32) TimeSpan(Int32, Int32, Int32) TimeSpan(Int32, Int32, Int32) TimeSpan(Int32, Int32, Int32)

TimeSpan 結構的新執行個體初始化為指定的時數、分鐘數和秒數。Initializes a new instance of the TimeSpan structure to a specified number of hours, minutes, and seconds.

TimeSpan(Int32, Int32, Int32, Int32) TimeSpan(Int32, Int32, Int32, Int32) TimeSpan(Int32, Int32, Int32, Int32) TimeSpan(Int32, Int32, Int32, Int32)

TimeSpan 結構的新執行個體初始化為指定的天數、時數、分鐘數和秒數。Initializes a new instance of the TimeSpan structure to a specified number of days, hours, minutes, and seconds.

TimeSpan(Int32, Int32, Int32, Int32, Int32) TimeSpan(Int32, Int32, Int32, Int32, Int32) TimeSpan(Int32, Int32, Int32, Int32, Int32) TimeSpan(Int32, Int32, Int32, Int32, Int32)

TimeSpan 結構的新執行個體初始化為指定的天數、時數、分鐘數、秒數和毫秒數。Initializes a new instance of the TimeSpan structure to a specified number of days, hours, minutes, seconds, and milliseconds.

欄位

MaxValue MaxValue MaxValue MaxValue

代表最大 TimeSpan 值。Represents the maximum TimeSpan value. 此欄位為唯讀。This field is read-only.

MinValue MinValue MinValue MinValue

代表最小 TimeSpan 值。Represents the minimum TimeSpan value. 此欄位為唯讀。This field is read-only.

TicksPerDay TicksPerDay TicksPerDay TicksPerDay

表示 1 天中的刻度數。Represents the number of ticks in 1 day. 這個欄位是常數。This field is constant.

TicksPerHour TicksPerHour TicksPerHour TicksPerHour

表示 1 小時中的刻度數。Represents the number of ticks in 1 hour. 這個欄位是常數。This field is constant.

TicksPerMillisecond TicksPerMillisecond TicksPerMillisecond TicksPerMillisecond

表示 1 毫秒中的刻度數。Represents the number of ticks in 1 millisecond. 這個欄位是常數。This field is constant.

TicksPerMinute TicksPerMinute TicksPerMinute TicksPerMinute

表示 1 分鐘中的刻度數。Represents the number of ticks in 1 minute. 這個欄位是常數。This field is constant.

TicksPerSecond TicksPerSecond TicksPerSecond TicksPerSecond

表示 1 秒中的刻度數。Represents the number of ticks in 1 second.

Zero Zero Zero Zero

代表零 TimeSpan 值。Represents the zero TimeSpan value. 此欄位為唯讀。This field is read-only.

屬性

Days Days Days Days

取得目前 TimeSpan 結構所表示之時間間隔的天數元件。Gets the days component of the time interval represented by the current TimeSpan structure.

Hours Hours Hours Hours

取得目前 TimeSpan 結構所表示之時間間隔的時數元件。Gets the hours component of the time interval represented by the current TimeSpan structure.

Milliseconds Milliseconds Milliseconds Milliseconds

取得目前 TimeSpan 結構所表示之時間間隔的毫秒數元件。Gets the milliseconds component of the time interval represented by the current TimeSpan structure.

Minutes Minutes Minutes Minutes

取得目前 TimeSpan 結構所表示之時間間隔的分鐘數元件。Gets the minutes component of the time interval represented by the current TimeSpan structure.

Seconds Seconds Seconds Seconds

取得目前 TimeSpan 結構所表示之時間間隔的秒數元件。Gets the seconds component of the time interval represented by the current TimeSpan structure.

Ticks Ticks Ticks Ticks

取得刻度數,表示目前 TimeSpan 結構的值。Gets the number of ticks that represent the value of the current TimeSpan structure.

TotalDays TotalDays TotalDays TotalDays

取得目前 TimeSpan 結構的值,這個值以整數和小數的天數表示。Gets the value of the current TimeSpan structure expressed in whole and fractional days.

TotalHours TotalHours TotalHours TotalHours

取得目前 TimeSpan 結構的值,這個值以整數和小數的時數表示。Gets the value of the current TimeSpan structure expressed in whole and fractional hours.

TotalMilliseconds TotalMilliseconds TotalMilliseconds TotalMilliseconds

取得目前 TimeSpan 結構的值,這個值以整數和小數的毫秒數表示。Gets the value of the current TimeSpan structure expressed in whole and fractional milliseconds.

TotalMinutes TotalMinutes TotalMinutes TotalMinutes

取得目前 TimeSpan 結構的值,這個值以整數和小數的分鐘數表示。Gets the value of the current TimeSpan structure expressed in whole and fractional minutes.

TotalSeconds TotalSeconds TotalSeconds TotalSeconds

取得目前 TimeSpan 結構的值,這個值以整數和小數的秒數表示。Gets the value of the current TimeSpan structure expressed in whole and fractional seconds.

方法

Add(TimeSpan) Add(TimeSpan) Add(TimeSpan) Add(TimeSpan)

傳回新的 TimeSpan 物件,它的值為指定之 TimeSpan 物件與這個執行個體的總和。Returns a new TimeSpan object whose value is the sum of the specified TimeSpan object and this instance.

Compare(TimeSpan, TimeSpan) Compare(TimeSpan, TimeSpan) Compare(TimeSpan, TimeSpan) Compare(TimeSpan, TimeSpan)

比較兩個 TimeSpan 值並傳回整數,這個整數會指出第一個值比第二個值短、等長或較長。Compares two TimeSpan values and returns an integer that indicates whether the first value is shorter than, equal to, or longer than the second value.

CompareTo(Object) CompareTo(Object) CompareTo(Object) CompareTo(Object)

比較這個執行個體和指定的物件,並傳回一個整數,表示這個執行個體短於、等於或長於指定的物件。Compares this instance to a specified object and returns an integer that indicates whether this instance is shorter than, equal to, or longer than the specified object.

CompareTo(TimeSpan) CompareTo(TimeSpan) CompareTo(TimeSpan) CompareTo(TimeSpan)

比較這個執行個體和指定的 TimeSpan 物件,並傳回一個整數,表示這個執行個體短於、等於或長於 TimeSpan 物件。Compares this instance to a specified TimeSpan object and returns an integer that indicates whether this instance is shorter than, equal to, or longer than the TimeSpan object.

Divide(TimeSpan) Divide(TimeSpan) Divide(TimeSpan) Divide(TimeSpan)
Divide(Double) Divide(Double) Divide(Double) Divide(Double)
Duration() Duration() Duration() Duration()

傳回新的 TimeSpan 物件,其值為目前 TimeSpan 物件的絕對值。Returns a new TimeSpan object whose value is the absolute value of the current TimeSpan object.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

傳回值,指出這個執行個體 (Instance) 是否和指定的物件相等。Returns a value indicating whether this instance is equal to a specified object.

Equals(TimeSpan) Equals(TimeSpan) Equals(TimeSpan) Equals(TimeSpan)

傳回表示這個執行個體是否等於指定 TimeSpan 物件的值。Returns a value indicating whether this instance is equal to a specified TimeSpan object.

Equals(TimeSpan, TimeSpan) Equals(TimeSpan, TimeSpan) Equals(TimeSpan, TimeSpan) Equals(TimeSpan, TimeSpan)

傳回值,這個值表示兩個指定的 TimeSpan 執行個體是否相等。Returns a value that indicates whether two specified instances of TimeSpan are equal.

FromDays(Double) FromDays(Double) FromDays(Double) FromDays(Double)

傳回表示指定天數的 TimeSpan,其規格的精確度達到最接近的毫秒數。Returns a TimeSpan that represents a specified number of days, where the specification is accurate to the nearest millisecond.

FromHours(Double) FromHours(Double) FromHours(Double) FromHours(Double)

傳回表示指定時數的 TimeSpan,其規格的精確度達到最接近的毫秒數。Returns a TimeSpan that represents a specified number of hours, where the specification is accurate to the nearest millisecond.

FromMilliseconds(Double) FromMilliseconds(Double) FromMilliseconds(Double) FromMilliseconds(Double)

傳回表示指定毫秒數的 TimeSpanReturns a TimeSpan that represents a specified number of milliseconds.

FromMinutes(Double) FromMinutes(Double) FromMinutes(Double) FromMinutes(Double)

傳回表示指定分鐘數的 TimeSpan,其規格的精確度達到最接近的毫秒數。Returns a TimeSpan that represents a specified number of minutes, where the specification is accurate to the nearest millisecond.

FromSeconds(Double) FromSeconds(Double) FromSeconds(Double) FromSeconds(Double)

傳回表示指定秒數的 TimeSpan,其規格的精確度達到最接近的毫秒數。Returns a TimeSpan that represents a specified number of seconds, where the specification is accurate to the nearest millisecond.

FromTicks(Int64) FromTicks(Int64) FromTicks(Int64) FromTicks(Int64)

傳回表示指定時間的 TimeSpan,其規格是以刻度為單位。Returns a TimeSpan that represents a specified time, where the specification is in units of ticks.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

傳回這個執行個體的雜湊碼。Returns a hash code for this instance.

Multiply(Double) Multiply(Double) Multiply(Double) Multiply(Double)
Negate() Negate() Negate() Negate()

傳回新 TimeSpan 物件,其值是這個執行個體的相反值。Returns a new TimeSpan object whose value is the negated value of this instance.

Parse(String) Parse(String) Parse(String) Parse(String)

將時間間隔的字串表示,轉換成與其相等的 TimeSpanConverts the string representation of a time interval to its TimeSpan equivalent.

Parse(ReadOnlySpan<Char>, IFormatProvider) Parse(ReadOnlySpan<Char>, IFormatProvider) Parse(ReadOnlySpan<Char>, IFormatProvider) Parse(ReadOnlySpan<Char>, IFormatProvider)
Parse(String, IFormatProvider) Parse(String, IFormatProvider) Parse(String, IFormatProvider) Parse(String, IFormatProvider)

使用指定的特定文化特性格式資訊,將時間間隔的字串表示轉換為其相等的 TimeSpanConverts the string representation of a time interval to its TimeSpan equivalent by using the specified culture-specific format information.

ParseExact(String, String, IFormatProvider, TimeSpanStyles) ParseExact(String, String, IFormatProvider, TimeSpanStyles) ParseExact(String, String, IFormatProvider, TimeSpanStyles) ParseExact(String, String, IFormatProvider, TimeSpanStyles)

使用指定之格式、特定文件特性格式資訊和樣式,將時間間隔的字串表示轉換為其相等的 TimeSpanConverts the string representation of a time interval to its TimeSpan equivalent by using the specified format, culture-specific format information, and styles. 字串表示的格式必須完全符合指定的格式。The format of the string representation must match the specified format exactly.

ParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, TimeSpanStyles) ParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, TimeSpanStyles) ParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, TimeSpanStyles) ParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, TimeSpanStyles)
ParseExact(String, String[], IFormatProvider, TimeSpanStyles) ParseExact(String, String[], IFormatProvider, TimeSpanStyles) ParseExact(String, String[], IFormatProvider, TimeSpanStyles) ParseExact(String, String[], IFormatProvider, TimeSpanStyles)

使用指定之格式、特定文件特性格式資訊和樣式,將時間間隔的字串表示轉換為其相等的 TimeSpanConverts the string representation of a time interval to its TimeSpan equivalent by using the specified formats, culture-specific format information, and styles. 字串表示的格式必須完全符合其中一個指定的格式。The format of the string representation must match one of the specified formats exactly.

ParseExact(String, String[], IFormatProvider) ParseExact(String, String[], IFormatProvider) ParseExact(String, String[], IFormatProvider) ParseExact(String, String[], IFormatProvider)

使用指定之格式字串的陣列和特定文件特性格式資訊,將時間間隔的字串表示轉換為其相等的 TimeSpanConverts the string representation of a time interval to its TimeSpan equivalent by using the specified array of format strings and culture-specific format information. 字串表示的格式必須完全符合其中一個指定的格式。The format of the string representation must match one of the specified formats exactly.

ParseExact(String, String, IFormatProvider) ParseExact(String, String, IFormatProvider) ParseExact(String, String, IFormatProvider) ParseExact(String, String, IFormatProvider)

使用指定之格式和特定文化特性格式資訊,將時間間隔的字串表示轉換為其相等的 TimeSpanConverts the string representation of a time interval to its TimeSpan equivalent by using the specified format and culture-specific format information. 字串表示的格式必須完全符合指定的格式。The format of the string representation must match the specified format exactly.

ParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, TimeSpanStyles) ParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, TimeSpanStyles) ParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, TimeSpanStyles) ParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, TimeSpanStyles)
Subtract(TimeSpan) Subtract(TimeSpan) Subtract(TimeSpan) Subtract(TimeSpan)

傳回新的 TimeSpan 物件,它的值為指定之 TimeSpan 物件與這個執行個體的差。Returns a new TimeSpan object whose value is the difference between the specified TimeSpan object and this instance.

ToString(String, IFormatProvider) ToString(String, IFormatProvider) ToString(String, IFormatProvider) ToString(String, IFormatProvider)

使用指定的格式和特定文件特性格式資訊,將目前 TimeSpan 物件的值,轉換為其相等的字串表示。Converts the value of the current TimeSpan object to its equivalent string representation by using the specified format and culture-specific formatting information.

ToString(String) ToString(String) ToString(String) ToString(String)

使用指定的格式,將目前 TimeSpan 物件的值,轉換為其相等字串表示。Converts the value of the current TimeSpan object to its equivalent string representation by using the specified format.

ToString() ToString() ToString() ToString()

將目前 TimeSpan 物件的值,轉換為其相等的字串表示。Converts the value of the current TimeSpan object to its equivalent string representation.

TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider) TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider) TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider) TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider)
TryParse(ReadOnlySpan<Char>, IFormatProvider, TimeSpan) TryParse(ReadOnlySpan<Char>, IFormatProvider, TimeSpan) TryParse(ReadOnlySpan<Char>, IFormatProvider, TimeSpan) TryParse(ReadOnlySpan<Char>, IFormatProvider, TimeSpan)
TryParse(ReadOnlySpan<Char>, TimeSpan) TryParse(ReadOnlySpan<Char>, TimeSpan) TryParse(ReadOnlySpan<Char>, TimeSpan) TryParse(ReadOnlySpan<Char>, TimeSpan)
TryParse(String, TimeSpan) TryParse(String, TimeSpan) TryParse(String, TimeSpan) TryParse(String, TimeSpan)

將時間間隔的字串表示,轉換為其相等的 TimeSpan,並傳回一個值表示轉換是否成功。Converts the string representation of a time interval to its TimeSpan equivalent and returns a value that indicates whether the conversion succeeded.

TryParse(String, IFormatProvider, TimeSpan) TryParse(String, IFormatProvider, TimeSpan) TryParse(String, IFormatProvider, TimeSpan) TryParse(String, IFormatProvider, TimeSpan)

使用指定的特定文件特性格式資訊,將時間間隔的字串表示轉換為其相等的 TimeSpan,並傳回表示轉換是否成功的值。Converts the string representation of a time interval to its TimeSpan equivalent by using the specified culture-specific formatting information, and returns a value that indicates whether the conversion succeeded.

TryParseExact(String, String, IFormatProvider, TimeSpanStyles, TimeSpan) TryParseExact(String, String, IFormatProvider, TimeSpanStyles, TimeSpan) TryParseExact(String, String, IFormatProvider, TimeSpanStyles, TimeSpan) TryParseExact(String, String, IFormatProvider, TimeSpanStyles, TimeSpan)

使用指定的格式、特定文件特性格式資訊和樣式,將時間間隔的字串表示轉換為其相等的 TimeSpan,並傳回表示轉換是否成功的值。Converts the string representation of a time interval to its TimeSpan equivalent by using the specified format, culture-specific format information, and styles, and returns a value that indicates whether the conversion succeeded. 字串表示的格式必須完全符合指定的格式。The format of the string representation must match the specified format exactly.

TryParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, TimeSpanStyles, TimeSpan) TryParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, TimeSpanStyles, TimeSpan) TryParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, TimeSpanStyles, TimeSpan) TryParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, TimeSpanStyles, TimeSpan)
TryParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, TimeSpanStyles, TimeSpan) TryParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, TimeSpanStyles, TimeSpan) TryParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, TimeSpanStyles, TimeSpan) TryParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, TimeSpanStyles, TimeSpan)
TryParseExact(String, String[], IFormatProvider, TimeSpan) TryParseExact(String, String[], IFormatProvider, TimeSpan) TryParseExact(String, String[], IFormatProvider, TimeSpan) TryParseExact(String, String[], IFormatProvider, TimeSpan)

使用指定的格式和特定文件特性格式資訊,將指定的時間間隔字串表示轉換為其相等的 TimeSpan,並傳回表示轉換是否成功的值。Converts the specified string representation of a time interval to its TimeSpan equivalent by using the specified formats and culture-specific format information, and returns a value that indicates whether the conversion succeeded. 字串表示的格式必須完全符合其中一個指定的格式。The format of the string representation must match one of the specified formats exactly.

TryParseExact(String, String[], IFormatProvider, TimeSpanStyles, TimeSpan) TryParseExact(String, String[], IFormatProvider, TimeSpanStyles, TimeSpan) TryParseExact(String, String[], IFormatProvider, TimeSpanStyles, TimeSpan) TryParseExact(String, String[], IFormatProvider, TimeSpanStyles, TimeSpan)

使用指定的格式、特定文件特性格式資訊和樣式,將指定的時間間隔字串表示轉換為其相等的 TimeSpan,並傳回表示轉換是否成功的值。Converts the specified string representation of a time interval to its TimeSpan equivalent by using the specified formats, culture-specific format information, and styles, and returns a value that indicates whether the conversion succeeded. 字串表示的格式必須完全符合其中一個指定的格式。The format of the string representation must match one of the specified formats exactly.

TryParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, TimeSpan) TryParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, TimeSpan) TryParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, TimeSpan) TryParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, TimeSpan)
TryParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, TimeSpan) TryParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, TimeSpan) TryParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, TimeSpan) TryParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, TimeSpan)
TryParseExact(String, String, IFormatProvider, TimeSpan) TryParseExact(String, String, IFormatProvider, TimeSpan) TryParseExact(String, String, IFormatProvider, TimeSpan) TryParseExact(String, String, IFormatProvider, TimeSpan)

使用指定的格式和特定文件特性格式資訊,將時間間隔的字串表示轉換為其相等的 TimeSpan,並傳回表示轉換是否成功的值。Converts the string representation of a time interval to its TimeSpan equivalent by using the specified format and culture-specific format information, and returns a value that indicates whether the conversion succeeded. 字串表示的格式必須完全符合指定的格式。The format of the string representation must match the specified format exactly.

運算子

Addition(TimeSpan, TimeSpan) Addition(TimeSpan, TimeSpan) Addition(TimeSpan, TimeSpan) Addition(TimeSpan, TimeSpan)

加入兩個指定的 TimeSpan 執行個體。Adds two specified TimeSpan instances.

Division(TimeSpan, TimeSpan) Division(TimeSpan, TimeSpan) Division(TimeSpan, TimeSpan) Division(TimeSpan, TimeSpan)
Division(TimeSpan, Double) Division(TimeSpan, Double) Division(TimeSpan, Double) Division(TimeSpan, Double)
Equality(TimeSpan, TimeSpan) Equality(TimeSpan, TimeSpan) Equality(TimeSpan, TimeSpan) Equality(TimeSpan, TimeSpan)

表示兩個 TimeSpan 執行個體是否相等。Indicates whether two TimeSpan instances are equal.

GreaterThan(TimeSpan, TimeSpan) GreaterThan(TimeSpan, TimeSpan) GreaterThan(TimeSpan, TimeSpan) GreaterThan(TimeSpan, TimeSpan)

表示指定的 TimeSpan 是否大於另一個指定的 TimeSpanIndicates whether a specified TimeSpan is greater than another specified TimeSpan.

GreaterThanOrEqual(TimeSpan, TimeSpan) GreaterThanOrEqual(TimeSpan, TimeSpan) GreaterThanOrEqual(TimeSpan, TimeSpan) GreaterThanOrEqual(TimeSpan, TimeSpan)

表示指定的 TimeSpan 是否大於或等於另一個指定的 TimeSpanIndicates whether a specified TimeSpan is greater than or equal to another specified TimeSpan.

Inequality(TimeSpan, TimeSpan) Inequality(TimeSpan, TimeSpan) Inequality(TimeSpan, TimeSpan) Inequality(TimeSpan, TimeSpan)

表示兩個 TimeSpan 執行個體是否不相等。Indicates whether two TimeSpan instances are not equal.

LessThan(TimeSpan, TimeSpan) LessThan(TimeSpan, TimeSpan) LessThan(TimeSpan, TimeSpan) LessThan(TimeSpan, TimeSpan)

表示指定的 TimeSpan 是否小於另一個指定的 TimeSpanIndicates whether a specified TimeSpan is less than another specified TimeSpan.

LessThanOrEqual(TimeSpan, TimeSpan) LessThanOrEqual(TimeSpan, TimeSpan) LessThanOrEqual(TimeSpan, TimeSpan) LessThanOrEqual(TimeSpan, TimeSpan)

表示指定的 TimeSpan 是否小於或等於另一個指定的 TimeSpanIndicates whether a specified TimeSpan is less than or equal to another specified TimeSpan.

Multiply(Double, TimeSpan) Multiply(Double, TimeSpan) Multiply(Double, TimeSpan) Multiply(Double, TimeSpan)
Multiply(TimeSpan, Double) Multiply(TimeSpan, Double) Multiply(TimeSpan, Double) Multiply(TimeSpan, Double)
Subtraction(TimeSpan, TimeSpan) Subtraction(TimeSpan, TimeSpan) Subtraction(TimeSpan, TimeSpan) Subtraction(TimeSpan, TimeSpan)

將指定的 TimeSpan 從另一個指定的 TimeSpan 減掉。Subtracts a specified TimeSpan from another specified TimeSpan.

UnaryNegation(TimeSpan) UnaryNegation(TimeSpan) UnaryNegation(TimeSpan) UnaryNegation(TimeSpan)

傳回 TimeSpan,其值是指定執行個體的相反值。Returns a TimeSpan whose value is the negated value of the specified instance.

UnaryPlus(TimeSpan) UnaryPlus(TimeSpan) UnaryPlus(TimeSpan) UnaryPlus(TimeSpan)

傳回 TimeSpan 的指定執行個體。Returns the specified instance of TimeSpan.

明確介面實作

IComparable.CompareTo(Object) IComparable.CompareTo(Object) IComparable.CompareTo(Object) IComparable.CompareTo(Object)

適用於

另請參閱