How to indicate that a method was unsuccessful

前端 未结 16 1514
走了就别回头了
走了就别回头了 2020-12-31 08:03

I have several similar methods, say eg. CalculatePoint(...) and CalculateListOfPoints(...). Occasionally, they may not succeed, and need to indicate this to the caller. For

16条回答
  •  鱼传尺愫
    2020-12-31 08:35

    Return Point.Empty. It's a .NET design patter to return a special field when you want to check if structure creation was successful. Avoid out parameters when you can.

    public static readonly Point Empty
    

提交回复
热议问题