TimeSpan.FromTicks メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > TimeSpan.FromTicks メソッドの意味・解説 

TimeSpan.FromTicks メソッド

指定した時間を表す TimeSpan を返します時間は、タイマ刻み単位指定します

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Shared Function FromTicks
 ( _
    value As Long _
) As TimeSpan
Dim value As Long
Dim returnValue As TimeSpan

returnValue = TimeSpan.FromTicks(value)
public static TimeSpan FromTicks (
    long value
)
public:
static TimeSpan FromTicks (
    long long value
)
public static TimeSpan FromTicks (
    long value
)
public static function FromTicks
 (
    value : long
) : TimeSpan

パラメータ

value

時間を表すタイマ刻み数。

戻り値
value の値を持つ TimeSpan

解説解説

このメソッドは、TimeSpan コンストラクタと同じ動作をする便利なメソッドです。

使用例使用例

FromTicks メソッド使用して複数TimeSpan オブジェクト作成するコード例次に示します

' Example of the TimeSpan.FromTicks( Long ) method.
Imports System
Imports Microsoft.VisualBasic

Module FromTicksDemo

    Sub GenTimeSpanFromTicks( ticks As Long
 )

        ' Create a TimeSpan object and TimeSpan string from 
        ' a number of ticks.
        Dim interval As TimeSpan = TimeSpan.FromTicks(
 ticks )
        Dim timeInterval As String
 = interval.ToString( )

        ' Pad the end of the TimeSpan string with spaces if it 
        ' does not contain milliseconds.
        Dim pIndex As Integer
 = timeInterval.IndexOf( ":"c )
        pIndex = timeInterval.IndexOf( "."c, pIndex
 )
        If pIndex < 0 Then   timeInterval
 &= "        "
        
        Console.WriteLine( "{0,21}{1,26}", ticks,
 timeInterval )
    End Sub 

    Sub Main( )

        Console.WriteLine( _
            "This example of TimeSpan.FromTicks( Long )"
 & _
            vbCrLf & "generates the following output."
 & vbCrLf )
        Console.WriteLine( "{0,21}{1,18}", _
            "FromTicks", "TimeSpan"
 )    
        Console.WriteLine( "{0,21}{1,18}", _
            "---------", "--------"
 )    

        GenTimeSpanFromTicks( 1 )
        GenTimeSpanFromTicks( 12345 )
        GenTimeSpanFromTicks( 123456789 )
        GenTimeSpanFromTicks( 1234567898765 )
        GenTimeSpanFromTicks( 12345678987654321 )
        GenTimeSpanFromTicks( 10000000 )
        GenTimeSpanFromTicks( 600000000 )
        GenTimeSpanFromTicks( 36000000000 )
        GenTimeSpanFromTicks( 864000000000 )
        GenTimeSpanFromTicks( 18012202000000 )
    End Sub 
End Module 

' This example of TimeSpan.FromTicks( Long )
' generates the following output.
' 
'             FromTicks          TimeSpan
'             ---------          --------
'                     1          00:00:00.0000001
'                 12345          00:00:00.0012345
'             123456789          00:00:12.3456789
'         1234567898765        1.10:17:36.7898765
'     12345678987654321    14288.23:31:38.7654321
'              10000000          00:00:01
'             600000000          00:01:00
'           36000000000          01:00:00
'          864000000000        1.00:00:00
'        18012202000000       20.20:20:20.2000000
// Example of the TimeSpan.FromTicks( long ) method.
using System;

class FromTicksDemo
{
    static void GenTimeSpanFromTicks( long
 ticks )
    {
        // Create a TimeSpan object and TimeSpan string from 
        // a number of ticks.
        TimeSpan    interval = TimeSpan.FromTicks( ticks );
        string      timeInterval = interval.ToString( );

        // Pad the end of the TimeSpan string with spaces if it 
        // does not contain milliseconds.
        int pIndex = timeInterval.IndexOf( ':' );
        pIndex = timeInterval.IndexOf( '.', pIndex );
        if( pIndex < 0 )   timeInterval += "        ";

        Console.WriteLine( "{0,21}{1,26}", ticks, timeInterval );
    } 

    static void Main( )
    {
        Console.WriteLine(
            "This example of TimeSpan.FromTicks( long )\n" +
            "generates the following output.\n" );
        Console.WriteLine( "{0,21}{1,18}", 
            "FromTicks", "TimeSpan" );
        Console.WriteLine( "{0,21}{1,18}", 
            "---------", "--------" );

        GenTimeSpanFromTicks( 1 );
        GenTimeSpanFromTicks( 12345 );
        GenTimeSpanFromTicks( 123456789 );
        GenTimeSpanFromTicks( 1234567898765 );
        GenTimeSpanFromTicks( 12345678987654321 );
        GenTimeSpanFromTicks( 10000000 );
        GenTimeSpanFromTicks( 600000000 );
        GenTimeSpanFromTicks( 36000000000 );
        GenTimeSpanFromTicks( 864000000000 );
        GenTimeSpanFromTicks( 18012202000000 );
    } 
} 

/*
This example of TimeSpan.FromTicks( long )
generates the following output.

            FromTicks          TimeSpan
            ---------          --------
                    1          00:00:00.0000001
                12345          00:00:00.0012345
            123456789          00:00:12.3456789
        1234567898765        1.10:17:36.7898765
    12345678987654321    14288.23:31:38.7654321
             10000000          00:00:01
            600000000          00:01:00
          36000000000          01:00:00
         864000000000        1.00:00:00
       18012202000000       20.20:20:20.2000000
*/
// Example of the TimeSpan::FromTicks( __int64 ) method.
using namespace System;
void GenTimeSpanFromTicks( __int64 ticks )
{
   
   // Create a TimeSpan object and TimeSpan string from 
   // a number of ticks.
   TimeSpan interval = TimeSpan::FromTicks( ticks );
   String^ timeInterval = interval.ToString();
   
   // Pad the end of the TimeSpan string with spaces if it 
   // does not contain milliseconds.
   int pIndex = timeInterval->IndexOf( ':' );
   pIndex = timeInterval->IndexOf( '.', pIndex );
   if ( pIndex < 0 )
      timeInterval = String::Concat( timeInterval, "        " );

   Console::WriteLine( "{0,21}{1,26}", ticks, timeInterval );
}

int main()
{
   Console::WriteLine( "This example of TimeSpan::FromTicks( __int64 )\n"
   "generates the following output.\n" );
   Console::WriteLine( "{0,21}{1,18}", "FromTicks", "TimeSpan"
 );
   Console::WriteLine( "{0,21}{1,18}", "---------", "--------"
 );
   GenTimeSpanFromTicks( 1 );
   GenTimeSpanFromTicks( 12345 );
   GenTimeSpanFromTicks( 123456789 );
   GenTimeSpanFromTicks( 1234567898765 );
   GenTimeSpanFromTicks( 12345678987654321 );
   GenTimeSpanFromTicks( 10000000 );
   GenTimeSpanFromTicks( 600000000 );
   GenTimeSpanFromTicks( 36000000000 );
   GenTimeSpanFromTicks( 864000000000 );
   GenTimeSpanFromTicks( 18012202000000 );
}

/*
This example of TimeSpan::FromTicks( __int64 )
generates the following output.

            FromTicks          TimeSpan
            ---------          --------
                    1          00:00:00.0000001
                12345          00:00:00.0012345
            123456789          00:00:12.3456789
        1234567898765        1.10:17:36.7898765
    12345678987654321    14288.23:31:38.7654321
             10000000          00:00:01
            600000000          00:01:00
          36000000000          01:00:00
         864000000000        1.00:00:00
       18012202000000       20.20:20:20.2000000
*/
// Example of the TimeSpan.FromTicks( long ) method.
import System.*;

class FromTicksDemo
{
    static void GenTimeSpanFromTicks(long ticks)
    {
        // Create a TimeSpan object and TimeSpan string from 
        // a number of ticks.
        TimeSpan interval = TimeSpan.FromTicks(ticks);
        String timeInterval = interval.ToString();

        // Pad the end of the TimeSpan string with spaces if it 
        // does not contain milliseconds.
        int pIndex = timeInterval.IndexOf(':');

        pIndex = timeInterval.IndexOf('.', pIndex);
        if (pIndex < 0) {
            timeInterval += "        ";
        }
        Console.WriteLine("{0,21}{1,26}", String.valueOf(ticks), timeInterval);
    } //GenTimeSpanFromTicks

    public static void main(String[]
 args)
    {
        Console.WriteLine(("This example of TimeSpan.FromTicks( long )\n"
 
            + "generates the following output.\n"));
        Console.WriteLine("{0,21}{1,18}", "FromTicks", "TimeSpan");
        Console.WriteLine("{0,21}{1,18}", "---------", "--------");
        GenTimeSpanFromTicks(1);
        GenTimeSpanFromTicks(12345);
        GenTimeSpanFromTicks(123456789);
        GenTimeSpanFromTicks(1234567898765L);
        GenTimeSpanFromTicks(12345678987654321L);
        GenTimeSpanFromTicks(10000000);
        GenTimeSpanFromTicks(600000000);
        GenTimeSpanFromTicks(36000000000L);
        GenTimeSpanFromTicks(864000000000L);
        GenTimeSpanFromTicks(18012202000000L);
    } //main
} //FromTicksDemo

/*
This example of TimeSpan.FromTicks( long )
generates the following output.

            FromTicks          TimeSpan
            ---------          --------
                    1          00:00:00.0000001
                12345          00:00:00.0012345
            123456789          00:00:12.3456789
        1234567898765        1.10:17:36.7898765
    12345678987654321    14288.23:31:38.7654321
             10000000          00:00:01
            600000000          00:01:00
          36000000000          01:00:00
         864000000000        1.00:00:00
       18012202000000       20.20:20:20.2000000
*/
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TimeSpan 構造体
TimeSpan メンバ
System 名前空間
Int64 構造体
FromMilliseconds
FromSeconds
FromMinutes
FromHours
FromDays



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

TimeSpan.FromTicks メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



TimeSpan.FromTicks メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS