Why are Exceptions not Checked in .NET?

前端 未结 10 1888
忘了有多久
忘了有多久 2020-11-27 03:36

I know Googling I can find an appropriate answer, but I prefer listening to your personal (and maybe technical) opinions.
What is the main reason of the differe

10条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 04:26

    I went from Java to C# because of a job change. At first, I was a little concerned about the difference, but in practice, it hasn't made a difference.

    Maybe, it's because I come from C++, which has the exception declaration, but it's not commonly used. I write every single line of code as if it could throw -- always use using around Disposable and think about cleanup I should do in finally.

    In retrospect the propagation of the throws declaration in Java didn't really get me anything.

    I would like a way to say that a function definitely never throws -- I think that would be more useful.

提交回复
热议问题