MyClass item = new MyClass();
VS nags me and wants to auto-fix this to:
MyClass item = new();
Then likes it just fine.
Unity hates this, and throws an error.
Why?
MyClass item = new MyClass();
VS nags me and wants to auto-fix this to:
MyClass item = new();
Then likes it just fine.
Unity hates this, and throws an error.
Why?
I’m assuming you’re on 2020 then. You can see what C# version Unity supports in the docs: Unity - Manual: C# compiler
The truncated new()
syntax is a new version language feature not supported in older versions.
In 2021 this syntax is supported. You can change your C# language version in your Visual Studio settings somewhere.