Creates a time span object, representing a given number of seconds. - CSharp System

CSharp examples for System:TimeSpan

Description

Creates a time span object, representing a given number of seconds.

Demo Code


using System.Globalization;
using System;//from  ww  w.j a v  a2  s.c o  m

public class Main{
        /// <summary>
    ///   <para>Creates a time span object, representing a given number of seconds.</para>
    /// </summary>
    /// <param name="self">Number of seconds.</param>
    /// <returns>Time span instance.</returns>
    public static TimeSpan Seconds(this int self)
    {
      return new TimeSpan(0, 0, self);
    }
        /// <summary>
    ///   <para>Creates a time span object, representing a given number of seconds.</para>
    /// </summary>
    /// <param name="self">Number of seconds.</param>
    /// <returns>Time span instance.</returns>
    public static TimeSpan Seconds(this short self)
    {
      return new TimeSpan(0, 0, self);
    }
        /// <summary>
    ///   <para>Creates a time span object, representing a given number of seconds.</para>
    /// </summary>
    /// <param name="self">Number of seconds.</param>
    /// <returns>Time span instance.</returns>
    public static TimeSpan Seconds(this byte self)
    {
      return new TimeSpan(0, 0, self);
    }
}

Related Tutorials