Friday, April 19, 2024 03:01

Posts Tagged ‘exceptions’

The Using directive

Sunday, August 5th, 2018

.NET provides a simplified and easier way of working with resources that needs to be disposed (released when we no longer need them) through construct called a Using directive. Here is an example of how we can read a filename (just like in our previous two lessons) and automatically release it when we are done dealing with it, using this keyword:

By enclosing the declaration of our reader variable inside the using instruction, we can use it just as we normally would, but we don’t need to worry about releasing the file when we are done with it.… Read more

Handling exceptions with Try Catch

Thursday, June 28th, 2018

Usually, when an exception is thrown, the program crashes or begins to malfunction. Fortunately, there is a way to prevent this that allows us to run codes that may generate exceptions, and still safely continue the execution in case of an error.… Read more

Exceptions

Sunday, June 17th, 2018

In an ideal world, a computer program will execute anything the programmer intended, the way the programmer intended. But since we don’t live in an ideal world (sadly), there are moments when due to the programmer’s mistake or to external conditions, these programs will malfunction or function in a way not intended, causing an exception from what we would normally expect.… Read more


Follow the white rabbit