C# Programming
02-05-2010, 03:22 PM
I want to add months and set the day as last day of that added month. I know i can do in the following way,
DateTime ldtManipulatedDate = new DateTime(1998,lintMonths,1).AddMonths(lintAddMonths);
ldtManipulatedDate = new DateTime(ldtManipulatedDate.Year ,ldtManipulatedDate.Months,DateTime.DaysInMonth(
ldtManipulatedDate.Year,ldtManipulatedDate.Months));
The above code will first add months and then set the day as last day of that added month.
But i want this in one step as i am instantiating two times.
Please let me know how can i do it?
DateTime ldtManipulatedDate = new DateTime(1998,lintMonths,1).AddMonths(lintAddMonths);
ldtManipulatedDate = new DateTime(ldtManipulatedDate.Year ,ldtManipulatedDate.Months,DateTime.DaysInMonth(
ldtManipulatedDate.Year,ldtManipulatedDate.Months));
The above code will first add months and then set the day as last day of that added month.
But i want this in one step as i am instantiating two times.
Please let me know how can i do it?