Re: [c#]回傳型態為物件,回傳值為null

看板Programming作者 (睡魔)時間18年前 (2006/12/18 09:40), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《mygame.bbs@bbs.ccns.ncku.edu.tw (逛逛)》之銘言: : 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
文章代碼(AID): #15XV6NL0 (Programming)
文章代碼(AID): #15XV6NL0 (Programming)