I'm using VS 2017 usually for console applications. But now I have to create a new ASP.NET MVC project and found something curious.
Auto generation of getter and setter (context menu "Quick actions and refactoring < Ecapsulate field (and use property)") raise a compiling error. To give an easy example:
public class Person
{
private string firstname;
public string Firstname { get => firstname; set => firstname = value; }
}
Error message:
1>------ Build started: Project: DummyASPNETMVC, Configuration: Debug Any CPU ------
1>C:\dev\C#\DummyASPNETMVC\DummyASPNETMVC\Models\Person.cs(12,39,12,41): error CS1043: { or ; expected
1>C:\dev\C#\DummyASPNETMVC\DummyASPNETMVC\Models\Person.cs(12,39,12,41): error CS1513: } expected
1>C:\dev\C#\DummyASPNETMVC\DummyASPNETMVC\Models\Person.cs(14,2,14,2): error CS1513: } expected
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Uncomment the getter and setter will make the things working again.
I'm wondering because this works fine within a console application. Where's the difference here?
Thanks to Panagiotis and Tetsuya. It was the version of c#.
As a reference to this question, you have to do three things:
done.
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