Home > Net >  Make a non grammatical errors, and then use the try... The catch... To capture
Make a non grammatical errors, and then use the try... The catch... To capture

Time:01-04

If the sentence has grammatical errors, the editor will be an error,
How to write a grammar mistakes, editor undetectable, but in the process of running from the try to catch?
 try 
{
//not grammar mistakes
}
The catch (e)
{
//jump to here
}

CodePudding user response:

Any number of divided by zero

CodePudding user response:

Create an object, the value is null, then access to its properties, the runtime will throw NullReferenceException anomalies

CodePudding user response:

Artificial control code if you want to run the catch block of code that can be directly where needed add throw new Exception (), also can put the catch in the corresponding block in the finally (whether abnormal or not, will eventually perform), the latter is more rigorous, the former path twisted,

CodePudding user response:

https://docs.microsoft.com/zh-cn/dotnet/csharp/programming-guide/exceptions/

CodePudding user response:

You can throw the new DivideByZeroException (), or "throw out what else the Exception, including your custom Excption subclass object,

CodePudding user response:

Throw new Exception (" you want Exception ");
  •  Tags:  
  • C#
  • Related