This will output "0":
TimeSpan span = TimeSpan.Zero;
span.Add(TimeSpan.FromMinutes(5));
Console.WriteLine(span.TotalSeconds); ----->
However, this will output "300":
TimeSpan span = TimeSpan.Zero.Add(TimeSpan.FromMinutes(5));
Console.WriteLine(span.TotalSeconds); ----->
Is this a known bug?
TimeSpan.Add
does not modify the input - it returns a new TimeSpan
which is the input plus the addend:
Remarks
The return value must be between TimeSpan.MinValue and TimeSpan.MaxValue; otherwise, an exception is thrown.
The return value is a new TimeSpan; the original TimeSpan is not modified.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With