how to add a DateTimeOffset to a DateTime in C#?

Sadly, DateTimeOffset is not what a normal person would understand from it's name. Simply put it's a DateTime WITH an offset (maybe not exactly just this; but close enough). Imo this is the worst named class in the whole .NET. The name came straight from SQL Server afaik. You can refer to this for details:

http://www.danrigsby.com/blog/index.php/2008/08/23/datetime-vs-datetimeoffset-in-net/


Documentation: http://msdn.microsoft.com/en-us/library/system.datetimeoffset.aspx says that DateTimeOffset already contains both a DateTime and an offset.

You probably want to use a TimeSpan instead of a DateTimeOffset. TimeSpan's can be added to DateTimes.

Tags:

C#

Datetime