When should I use Debug.Assert()?

后端 未结 20 1665
说谎
说谎 2020-11-30 16:12

I\'ve been a professional software engineer for about a year now, having graduated with a CS degree. I\'ve known about assertions for a while in C++ and C, but had no idea t

20条回答
  •  失恋的感觉
    2020-11-30 16:57

    You should always use the second approach (throwing exceptions).

    Also if you're in production (and have a release-build), it's better to throw an exception (and let the app crash in the worst-case) than working with invalid values and maybe destroy your customer's data (which may cost thousand of dollars).

提交回复
热议问题