โ Back to Exceptions
Question 674
Null Reference Handling
Null Reference Handling
The variabletextis set tonull. Readingtext.Lengthon a null reference throws aNullReferenceException. Catch it and print exactlyCannot read a null reference. Use top-level statements withtry/catch. This program reads no input. The program always prints: Cannot read a null reference
Expected Output:
Cannot read a null reference
Topics:
Exceptions
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.