Saturday, October 24, 2015

Keywords - checked & unchecked

First understand scenarios where we can use checked & unchecked keywords

C# compiler does not throws any error at compile or run time for arithmetic overflow.
j has assigned wrong value.
checked:  Used to check arithmetic overflow, it throws arithmetic overflow exception in case of overflow.



C# compiler checks for arithmetic overflow if constant(s) involved in operation and gives compile time error.
unchecked: unchecked is used to suppress checking for arithmetic overflow by compiler

No comments:

Post a Comment

Node | Cluster Vs Worker Threads

Cluster: Multiple processes (scale app across CPU cores) Worker Threads: Multiple threads (handle CPU-heavy work inside one process) Cluster...