课程: Learning C#
今天就学习课程吧!
今天就开通帐号,24,600 门业界名师课程任您挑!
Exceptions
- [Illustrator] Just like in life, sometimes things go wrong in our programs and it's necessary to handle those conditions so that the user doesn't get a bad experience. In C#, like in some other languages, we use a programming technique called exception handling to catch errors before they make their way to the user. So let's take a look at how this works. Here in my code in the exceptions folder, I'll open up the Program File. So here in my example code. I have a few variables with some values and I'm going to do a simple math operation. I'm going to assign the result to the value of X divided by Y. So that works fine, just as long as I don't try to do something foolish, like divide by zero. So let's make that change and see what happens. So I make y zero and save this and let's go ahead and bring up our terminal, and what I'm going to do is run this now. So when I run the code, I think that's going to try to…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。