C# try {} catch {}

后端 未结 11 2412
既然无缘
既然无缘 2021-02-08 10:51

hi and thanks for reading. im a newbie in programming and C# and sockets programming. in my code i try and catch problems to provide fault tolarence in my app. the following:

11条回答
  •  [愿得一人]
    2021-02-08 11:04

    While you can do that , I'd consider it poor practice and not how you'd want to be structuring your code.

    Depending on the exception you may want to do something different. An invalid IP is a different issue than a hardware error and so on. Additionally some errors you might want to notify back to the UI via a delegate or log somewhere using log4net.

    But that's just me and I'm far from an expert - so take it for what it's worth

提交回复
热议问题