try this...
using System;
public class MyClass {
private static void GetMonthEnd(System.DateTime dateIn, ref System.DateTime dateOut){
dateIn = dateIn.AddMonths(1);
dateIn = dateIn.AddDays(-1);
dateOut = new System.DateTime(dateIn.Year, dateIn.Month, dateIn.Day);
}
public static int Main(string[] args) {
System.DateTime jan = new System.DateTime(2005,3,1);
System.DateTime endOfJan = new System.DateTime();
GetMonthEnd(jan, ref endOfJan);
Console.WriteLine("Jan: {0}", jan);
Console.WriteLine("endOfJan: {0}", endOfJan);
Console.Write("\nPress any key to continue...");
Console.ReadKey();
return 0;
}
}