The code I'm working with has an existing try catch block. The catch block is below. In the try block, I need to manually throw an exception if a condition is met.
catch (Exception ex)
What is the correct way to throw an exception? Will this work? The reason I ask is because the catch block seems to accept a single parameter of type Exception. But I'm passing a string, so that's why I'm a bit confused on how to properly throw an exception with a string message.
string errorMsg = "This is an error.";
throw new Exception(errorMsg);