delegate void F();
class A
{
static void Foo()
{
F f = unchecked(delegate
{
constbyte x = (byte)-1; // error CS0221: Constant value '-1' cannot be converted to a 'byte' (use 'unchecked' syntax to override)
});
}
}
See C# 3.0 Specification Draft, 7.5.12 The checked and unchecked operators
The body of an anonymous function is not affected by checked or unchecked contexts in which the anonymous function occurs.
Description
delegate void F();
class A
{
static void Foo()
{
F f = unchecked(delegate
{
constbyte x = (byte)-1; // error CS0221: Constant value '-1' cannot be converted to a 'byte' (use 'unchecked' syntax to override)
});
}
}
See C# 3.0 Specification Draft, 7.5.12 The checked and unchecked operators
The body of an anonymous function is not affected by checked or unchecked contexts in which the anonymous function occurs.