vb System.TimeSpan.Negate类(方法)实例源码

下面列出了vb System.TimeSpan.Negate 类(方法)源码代码实例,从而了解它的用法。

作者:VB.NET开发    项目:Syste   
' Example of the TimeSpan.Duration( ) and TimeSpan.Negate( ) methods,
' and the TimeSpan Unary Negation and Unary Plus operators.
Module DuraNegaUnaryDemo

    Const dataFmt As String = "{0,22}{1,22}{2,22}"

    Sub ShowDurationNegate( interval As TimeSpan )

        ' Display the TimeSpan value and the results of the 
        ' Duration and Negate methods.
        Console.WriteLine( dataFmt, _
            interval, interval.Duration( ), interval.Negate( ) )
    End Sub

    Sub Main( )

        Console.WriteLine( _
            "This example of TimeSpan.Duration( ), " & _
            "TimeSpan.Negate( ), " & vbCrLf & _
            "and the TimeSpan Unary Negation and " & _
            "Unary Plus operators " & vbCrLf & _
            "generates the following output." & vbCrLf )
        Console.WriteLine( dataFmt, _
            "TimeSpan", "Duration( )", "Negate( )" )    
        Console.WriteLine( dataFmt, _
            "--------", "-----------", "---------" )    

        ' Create TimeSpan objects and apply the Unary Negation
        ' and Unary Plus operators to them.
        ShowDurationNegate( new TimeSpan( 1 ) )
        ShowDurationNegate( new TimeSpan( -1234567 ) )
        ShowDurationNegate( TimeSpan.op_UnaryPlus( _
            new TimeSpan( 0, 0, 10, -20, -30 ) ) )
        ShowDurationNegate( TimeSpan.op_UnaryPlus( _
            new TimeSpan( 0, -10, 20, -30, 40 ) ) )
        ShowDurationNegate( TimeSpan.op_UnaryNegation( _
            new TimeSpan( 1, 10, 20, 40, 160 ) ) )
        ShowDurationNegate( TimeSpan.op_UnaryNegation( _
            new TimeSpan( -10, -20, -30, -40, -50 ) ) )
    End Sub 
End Module 

' This example of TimeSpan.Duration( ), TimeSpan.Negate( ),
' and the TimeSpan Unary Negation and Unary Plus operators


问题


面经


文章

微信
公众号

扫码关注公众号