Negate a TimeSpan

In this chapter you will learn:

  1. How to negate a TimeSpan

TimeSpan negation

using System;/*jav a 2 s . com*/

class MainClas
{
  public static void Main()
  {
    TimeSpan myTimeSpan13 = new TimeSpan(1, 10, 13);
    TimeSpan myTimeSpan14 = new TimeSpan(2, 6, 10);
    TimeSpan myTimeSpan15 = myTimeSpan13.Subtract(myTimeSpan14);
    
    
    Console.WriteLine("myTimeSpan15.Negate() = " + myTimeSpan15.Negate());
    Console.WriteLine("myTimeSpan14.Negate() = " + myTimeSpan14.Negate());


  }
}

Next chapter...

What you will learn in the next chapter:

  1. What are Overloaded Operators for TimeSpan
  2. Using Subtract operators with TimeSpan
Home » C# Tutorial » Date, Time, TimeZone
Compare DateTimeOffset
DateTimeOffset creation
Date time Value from DateTimeOffset
Compare DateTime value
DateTime constant value
DateTime constructor
DateTime properties
Create TimeSpan From
TimeSpan
TimeSpan add and subtract
DateTime and TimeSpan
Compare TimeSpan
TimeSpan constant
TimeSpan Constructor
TimeSpan Duration
TimeSpan format
Negate a TimeSpan
TimeSpan operators
Parse string to TimeSpan
TimeSpan to string
TimeSpan total properties
TimeSpan propeties
Daylight saving
Time zone ID
UTC offset with TimeZone
TimeZone converting
TimeZone creation