I have started learning C# and Web API recently. When I created a new ASP .NET Core Web Application in Visual Studio 2019, it generated some code for WeatherForecast. Following is code segment that I am having trouble understanding.
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
What is operator => doing here? CreateHostBuilder is a static method of class Program. And its definition should start with { and end with }. But after the closing braces of argument list, operator => is placed. I don't understand how this syntax works. Appreciate help in understanding this. Thanks