• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: can only throw exceptions in C# functions?

Resolved: can only throw exceptions in C# functions?

0
By Isaac Tonny on 15/03/2023 Issue
Share
Facebook Twitter LinkedIn

In this post, we will see how to resolve can only throw exceptions in C# functions?

Question:

I’ve written a custom exception and want it to be thrown when the parking hours exceed 24hrs. I firstly placed the throw exception in the parent class property HoursParked but it never throws when I debug the program. Then I moved it to a function within the same class and it worked fine. Does it mean we can only throw exceptions in a function definition? Hope to get some insights into this as I don’t fully understand the mechanism of exception handling even after resear
ching various documents. Thanks

Best Answer:

Well, exceptions are designed for exceptional situations only. In our case it seems that we can have such behavior in the set only:

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com

c# exception
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: I am facing ERR_HTTP2_PROTOCOL_ERROR on my website

27/03/2023

Resolved: TypeScript does not recognize properties when instantiating interface array

27/03/2023

Resolved: How to make statement case insensitive when uploading a dta file with specified columns?

27/03/2023

Comments are closed.

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.