C# 8 features are usually not enabled by default when creating new projects in Visual Studio. However, it's fairly simple to enable, but it does involve editing the project file manually. Follow these few steps to do so:
- Right-click the News project node and click Edit Project File, as illustrated in the following screenshot:
- Add the following line marked in bold to the project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<!-- xml removed for brevity -->
</Project>
That's it. We've now specified that we want to use C# 8. You could also specify latest as the value of the LangVersion tag. The next step is to create the NewsService class that will wrap the call to the News API.