What I want to do is have a user enter a date and have a class that returns the last day of the month. So, I've put this in my class module:
public static class StringExtensions
{
public static DateTime LastDayOfMonth(DateTime MyDate)
{
DateTime today = MyDate;
DateTime EOM = new DateTime(today.Year,today.Month,
DateTime.DaysInMonth(today.Year,
today.Month));
return EOM;
}
}
In my code-behind, I have this:
DateTime LDOM = StringExtensions.LastDayOfMonth(txtCIT.Text);
I've also tried hard-coding a date like:
DateTime LDOM = StringExtensions.LastDayOfMonth('1/12/2016');
I'm getting these errors:
Error 14 The best overloaded method match for 'ClientDPL.StringExtensions.LastDayOfMonth(System.DateTime)' has some invalid arguments
and
Error 15 Argument 1: cannot convert from 'string' to 'System.DateTime'
Can anyone see what I'm doing wrong?