TimeSpan

TimeSpan CF 1.0, ECMA 1.0, serializable

System (mscorlib.dll) struct

This class encapsulates a positive or negative interval of time that can be used for arithmetic operations and greater-than or less-than comparisons. Internally, the TimeSpan is stored as a number of ticks , each of which is equal to 100 nanoseconds. You can convert a string into a TimeSpan using the static Parse( ) method.

You can evaluate a time span in terms of days, hours, seconds, and so on, by using the appropriate Total property. The corresponding properties that are not preceded with the word Total return only one component of the time span. (For example, the TotalHours property returns 1.5 for a time span of an hour and a half, while Hours returns 1 for a time span of one hour.)

The TimeSpan static methods prefixed with From are useful for quickly creating a time span for use as an argument for a method call, as in myApp.SetTimeSpan(TimeSpan.FromMinutes(10)) .

 public struct  TimeSpan  : IComparable {  // Public Constructors  public  TimeSpan  (int   hours   , int   minutes   , int   seconds   );    public  TimeSpan  (int   days   , int   hours   , int   minutes   , int   seconds   );    public  TimeSpan  (int   days   , int   hours   , int   minutes   , int   seconds   , int   milliseconds   );    public  TimeSpan  (long   ticks   );  // Public Static Fields  public static readonly TimeSpan  MaxValue  ;  // =10675199.02:48:05.4775807  public static readonly TimeSpan  MinValue  ;  // =-10675199.02:48:05.4775808  public const long  TicksPerDay  ;  // =864000000000  public const long  TicksPerHour  ;  // =36000000000  public const long  TicksPerMillisecond  ;  // =10000  public const long  TicksPerMinute  ;  // =600000000  public const long  TicksPerSecond  ;  // =10000000  public static readonly TimeSpan  Zero  ;  // =00:00:00   // Public Instance Properties  public int  Days  {get; }    public int  Hours  {get; }    public int  Milliseconds  {get; }    public int  Minutes  {get; }    public int  Seconds  {get; }    public long  Ticks  {get; }    public double  TotalDays  {get; }    public double  TotalHours  {get; }    public double  TotalMilliseconds  {get; }    public double  TotalMinutes  {get; }    public double  TotalSeconds  {get; }  // Public Static Methods  public static int  Compare  (TimeSpan   t1   , TimeSpan   t2   );    public static bool  Equals  (TimeSpan   t1   , TimeSpan   t2   );    public static TimeSpan  FromDays  (double   value   );    public static TimeSpan  FromHours  (double   value   );    public static TimeSpan  FromMilliseconds  (double   value   );    public static TimeSpan  FromMinutes  (double   value   );    public static TimeSpan  FromSeconds  (double   value   );    public static TimeSpan  FromTicks  (long   value   );    public static TimeSpan  Parse  (string   s   );    public static TimeSpan operator  -  (TimeSpan   t   );    public static TimeSpan operator  -  (TimeSpan   t1   , TimeSpan   t2   );    public static TimeSpan operator  +  (TimeSpan   t   );    public static TimeSpan operator  +  (TimeSpan   t1   , TimeSpan   t2   );    public static bool operator  !=  (TimeSpan   t1   , TimeSpan   t2   );    public static bool operator  <  (TimeSpan   t1   , TimeSpan   t2   );    public static bool operator  <=  (TimeSpan   t1   , TimeSpan   t2   );    public static bool operator  =  =  (TimeSpan   t1   , TimeSpan   t2   );    public static bool operator  >  (TimeSpan   t1   , TimeSpan   t2   );    public static bool operator  >=  (TimeSpan   t1   , TimeSpan   t2   );  // Public Instance Methods  public TimeSpan  Add  (TimeSpan   ts   );    public int  CompareTo  (object   value   );  // implements IComparable  public TimeSpan  Duration  ( );    public override bool  Equals  (object   value   );  // overrides ValueType  public override int  GetHashCode  ( );  // overrides ValueType  public TimeSpan  Negate  ( );    public TimeSpan  Subtract  (TimeSpan   ts   );    public override string  ToString  ( );  // overrides ValueType  } 

Hierarchy

Object ValueType TimeSpan(IComparable)

Returned By

DateTime.{Subtract( ) , TimeOfDay} , System.Diagnostics.Process.{PrivilegedProcessorTime , TotalProcessorTime , UserProcessorTime} , System.Diagnostics.ProcessThread.{PrivilegedProcessorTime , TotalProcessorTime , UserProcessorTime} , System.Globalization.DaylightTime.Delta , TimeZone.GetUtcOffset( ) , System.Xml.XmlConvert.ToTimeSpan( )

Passed To

Multiple types



C# in a Nutshell
C # in a Nutshell, Second Edition
ISBN: 0596005261
EAN: 2147483647
Year: 2005
Pages: 963

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net