Hans and Giri,
That seems much, much longer than this:
public static int DaysInYear(DateTime value)
{
// Get the year. Construct dates for New Year's Day, and subtract.
int pintYear = value.Year;
// Now construct dates and subtract from each other to get the return
value.
int pintRetVal = (new DateTime(pintYear + 1, 1, 1) - new
DateTime(pintYear, 1, 1)).Days;
// That's all folks.
return pintRetVal;
}
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
"Giri" <gt******@prologis.com> wrote in message
news:ei**************@TK2MSFTNGP09.phx.gbl... what is the easiest way of establishing this given a Year?
(short of DateTime.parsing a made up string representing 1/1 to 31/12
blah blah blah)
Thanks
Giri
DateTime has a static DayInMonth method that accepts a year and a month.
You could loop through all 12 months for a given year, or just check the
number of days in februari to select either 365 or 366 days.
Hans Kesting