Is there are difference new struct() or without ()

Hi, was just wondering if there is a difference between these two,
one with () and one without if I define the values directly?

Struct StructName = new Struct() {
    A = 1, B=2, C=3
};
Struct StructName = new Struct {
    A = 1, B=2, C=3
};

No, all three:

Struct StructName = new Struct() {
    A = 1, B=2, C=3
};
Struct StructName = new Struct {
    A = 1, B=2, C=3
};
Struct StructName = new() {
    A = 1, B=2, C=3
};

will produce the same lowered C# code.

1 Like