Until this very day, I could make use of primary constructors, such as:
public class Test(string text) { private string mText = text; }
To be able to do this, in the previous Visual Studio CTP, I had to add this to the csproj-file:
<LangVersion>Experimental</LangVersion>
Anyhow, this no longer works in the Visual Studio 2015 Preview (with or without LangVersion
). Does anyone have any ideas about what could be going on?
Place your cursor on the instance. Press Ctrl+. to trigger the Quick Actions and Refactorings menu. Select Generate constructor in <QualifiedName> (with properties).
Basically a Primary Constructor is a feature of C# that was announced with Visual Studio 2014 by which a class or structure can accept parameters in the class definition without a formal constructor declaration.
Type ctor, and then press the Tab key.
Does anyone have any ideas about what could be going on?
Yup - primary constructors have been removed from the plans for C# 6. They may well make an appearance in some form in a later version, but they're not in C# 6 any more.
See the "Changes to the language feature set" post from the team for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With