I’m using Visual Studio 2015. Is there a problem in the code? Please guide. I’m also still a beginner in C#.
public partial class Root : Form
{
private BindingList<Product> list = null;
private BindingSource bindingSource = null;
public Root() => InitializeComponent();
}
>Solution :
You are using an old version of C# that comes with Visual Studio 2015. If you can, you should upgrade to Visual Studio 2022, so that you can use language features like expression bodied constructors.
If you cannot or do not want to upgrade to the latest Visual Studio and C# versions, then the easy fix is to change the constructor like this:
public partial class Root : Form
{
//...
public Root()
{
InitializeComponent();
}
}
As Jon Skeet noted, expression-bodied constructors are only supported in C# 7.0 and higher.