Why does this C# code throw an error: Use of unassigned local variable 'n'

前端 未结 4 535
我在风中等你
我在风中等你 2021-01-21 05:26

On MSDN, this code is posted at https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/try-catch I am unable to understand why it throws the error:

4条回答
  •  失恋的感觉
    2021-01-21 06:02

    This error is because you are using n in Console.Write() function. And suppose if Try block generates an exception then n would not be initialized. Therefore this error occurs.

提交回复
热议问题