I have a c# DateTime object and I need to increment it by one month.
example:
input output ------------------------------- Jan 12, 2005 Feb 12, 2005 Feb 28, 2009 Mar 28, 2009 Dec 31, 2009 Jan 31, 2010 Jan 29, 2000 Feb 29, 2000 Jan 29, 2100 Error: no Feb 29, 2100
What is the best way to do this.
My first thought (aside from some built in code) was to construct a new DateTime from pieces and handle the roll to the year myself
Here’s a complete program showing the examples given in the question. You’d probably want to use an exception in OneMonthAfter if it really shouldn’t be called that way.