C#: Do you raise or throw an exception

c++exceptionraiseterminologythrow

I know that this probably doesn't really matter, but I would like to know what is correct.

If a piece of code contains some version of throw new SomeKindOfException(). Do we say that this piece of code can potentially raise an exception? Or throw an exception?

The keyword is throw, so I am kind of leaning towards that, but to raise an exception is also used a lot…

Do they have some sort of different meaning? Does one of them sort of implicate a difference over the other? Or is it just two words meaning exactly the same thing?

Best Solution

In C# terminology, raising is used in the context of events and throwing is used in the context of exceptions.

Personally, I think throw/catch combination is more beautiful than raise/catch.