开发者

C# - Datetime convertion and GetDayOfYear usage fails

There's the code:

HebrewCalendar 开发者_如何学运维Heb = new HebrewCalendar();
DateTime tmp = new DateTime(1964,2,3);
MessageBox.Show(Heb.GetDayOfYear(tmp));

it's very basic and simple, but yet - i get an errors:

Error 1 The best overloaded method match for System.Windows.Forms.MessageBox.Show(string)' has some invalid arguments..

Error 2 Argument 1: cannot convert from 'int' to 'string'

what is the problem?


I'm not familiar with HebrewCalendar, but given the error message, I'd say that GetDayOfYear is returning an integer.

Try this:

MessageBox.Show(Heb.GetDayOfYear(tmp).ToString());

MessageBox.Show doesn't know how to deal with integers. If you convert it to a string first, it will show you the string representation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜