This isn't an error?
I just saw something odd in a diff before a check-in. Basically, I had a trailing comma in an object initializer:
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var foo = new Foo
{
A = "A",
B = "B",
};
}
}
class Foo
{
public string A { get; set; }
public string B { get; set; }
}
}
I thought this would be an error until I did some searching and found that it is allowed according to "ECMA-334: 19.7 Array initializers":
[Note: Like Standard C++, C# allows a trailing comma at the end of an array-initializer. This syntax provides flexibility in adding or deleting members from such a list, and simplifies machine generation of such lists. end note]