Use of Checked and UnChecked operators?

Answers were Sorted based on User's Feedback



Use of Checked and UnChecked operators?..

Answer / jackir

when value of a datatype excided its limitaion then its
call overflow to avoid this problem we use ckecked and
unchecked
syntax
return unchecked(x+y);
return checked(x+y);

Is This Answer Correct ?    9 Yes 0 No

Use of Checked and UnChecked operators?..

Answer / hridya

In a checked context, if the operation is a constant
expression a compile-time error occurs. Otherwise, when the
operation is performed at run-time, a
System.OverflowException is thrown.

In an unchecked context, the result is truncated by
discarding any high-order bits that do not fit in the
destination type.

Is This Answer Correct ?    4 Yes 0 No

Post New Answer

More C Sharp Interview Questions

Is xml tags are case sensitive?

0 Answers  


Explain the mechanism of VB.NET/C# achieve polymorphism?

0 Answers   Siebel,


Okay, so an int is a value type, and a class is a reference type. How can int be derived from object?

0 Answers  


What is an escape sequence in c#?

0 Answers  


how to Create a datagridview control with check box column with 8rows in it, the maximum number of check boxes checked should be 3, when user checks the 4th corresponding message should be displayed and check box should be checked. User can uncheck the checked boxes Note: read-only property should not be used

0 Answers   HCL, NIC,






can we assign null value to value type in c#?

12 Answers   Idea, Microsoft, Wipro,


Can you instantiate an abstract class c#?

0 Answers  


What is action c#?

0 Answers  


Is there a way to force garbage collection?

0 Answers  


Structs are not reference types. Can structs have constructors?

0 Answers  


Is namespace a class?

0 Answers  


How does c# achieve polymorphism?

0 Answers  


Categories