the below example shows that a variable is set to null and when we try to print it, it throws an exception that gets caught in the catch −
try { a = null; console.writeline(a);}catch (nullpointerexception ex) { console.writeline("variable is null!");}
上述代码将允许捕获异常并使用catch处理它。
以上就是c# 中的空指针异常的详细内容。
