作者leicheong (睡魔)
看板Programming
标题Re: [c#]回传型态为物件,回传值为null
时间Mon Dec 18 09:45:26 2006
※ 引述《[email protected] (逛逛)》之铭言:
: public RectangleF GetCollisionMBR()
: {
: //...
: return bCollisionMBRExists ? rfCollisionBoundingBox : null;
: } ↑ ↑
: bool RectangleF
: 跑出错误
: Type of conditional expression cannot be determined because there is no
: implicit conversion between 'System.Drawing.RectangleF' and '<null>'
: 请问这里要怎麽改?
: 感谢大德!
RectangleF是struct而不是object, 因此请用RectangleF.Empty代替.
就像用System.IntPtr时用IntPtr.Zero一样, struct的话很多时候
都不是nullable type, 而需要用特定的member表示「非正常」的值...
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 202.134.126.84