当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET TimeSpan.UnaryNegation操作符代码示例

本文整理汇总了VB.NET中System.TimeSpan.UnaryNegation操作符的典型用法代码示例。如果您正苦于以下问题:VB.NET TimeSpan.UnaryNegation操作符的具体用法?VB.NET TimeSpan.UnaryNegation怎么用?VB.NET TimeSpan.UnaryNegation使用的例子?那么恭喜您, 这里精选的操作符代码示例或许可以为您提供帮助。您也可以进一步了解该操作符所在System.TimeSpan的用法示例。


在下文中一共展示了TimeSpan.UnaryNegation操作符的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: DuraNegaUnaryDemo

' 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
开发者ID:VB.NET开发者,项目名称:System,代码行数:44,代码来源:TimeSpan.UnaryNegation

输出:

TimeSpan           Duration( )             Negate( )
--------           -----------             ---------
00:00:00.0000001      00:00:00.0000001     -00:00:00.0000001
-00:00:00.1234567      00:00:00.1234567      00:00:00.1234567
00:09:39.9700000      00:09:39.9700000     -00:09:39.9700000
-09:40:29.9600000      09:40:29.9600000      09:40:29.9600000
-1.10:20:40.1600000    1.10:20:40.1600000    1.10:20:40.1600000
10.20:30:40.0500000   10.20:30:40.0500000  -10.20:30:40.0500000


注:本文中的System.TimeSpan.UnaryNegation操作符示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。