Get the value of TimeSpan in whole and fractional milliseconds in CSharp

Description

The following code shows how to get the value of TimeSpan in whole and fractional milliseconds.

Example


using System;/*from  w  ww . j av a 2s  .co m*/

public class Example
{
   public static void Main()
   {
      // Define an interval of 1 day, 15+ hours.
      TimeSpan interval = new TimeSpan(1, 15, 42, 45, 750); 
      Console.WriteLine("Value of TimeSpan: {0}", interval);

      Console.WriteLine("There are {0:N5} milliseconds, as follows:", interval.TotalMilliseconds);

   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var