Code inspection: Redundant braces in collection initializer
This inspection reports braces around a collection initializer element when the element contains only a single non-assignment value. In that case, the extra braces are unnecessary and make the initializer harder to read.
using System.Collections;
class C
{
object Create()
{
return new ArrayList { 1, { 2 } };
}
}
using System.Collections;
class C
{
object Create()
{
return new ArrayList { 1, 2 };
}
}
This inspection does not report elements where the braces are required, such as multi-argument Add(...) calls.
13 April 2026