C# Unchecked Statement

unchecked-statements
In this chapter you will learn:

  • What is unchecked statement in C#?
  • What is the advantage and disadvantage of Unchecked Statement?
  • How to use unchecked statement in C sharp programming?

The unchecked statement ignores the stack overflow exception and executes the program so, the output can be incorrect.

Example:





  • Here, the correct output should be 2147483648 but the output is -2147483648 which is wrong because of unchecked statements as it ignores exception and put output on screen.

    Output

    -2147483648
    __

    Summary

    In this chapter you learned what unchecked statement is in C# and how to use it in programming. In next chapter you will learn about Lock Statement in C#.


    One thought on “C# Unchecked Statement”

    Leave a Reply

    Your email address will not be published. Required fields are marked *