Reputation: 2848
I have this code
MyClass instance = new MyClass();
VS Intellisense shows:
'new' expression can be simplified
and upon selecting that action, it changes the code to:
MyClass instance = new();
but then build fails with error code CS8181:
'new' cannot be used with tuple type. Use a tuple literal expression instead.
I am unable to understand this error message as MyClass
is not related to tuple
type. It's a plain class with int
, string
and list
properties and no inheritance. Also, why should an Intellisense suggested action cause an error.
I've reported this issue to VS Dev Community. Link
Thanks in advance for your help.
Upvotes: 6
Views: 7147
Reputation: 335
As documented here this available if you use C#9.0+. I guess that you use lower version of C# than required.
Upvotes: 5