Category: C#

C# Compiler Warning – CS1998 this async method lacks ‘await’ operator

In this blog post, you’ll learn more about the C# Compiler Warning – CS1998 and the related message description C# Compiler Warning Code CS1998 C# Compiler Description for the Code :CS1998 This async method lacks ‘await’ operators and will run synchronously. Consider using the ‘await’ operator to await non-blocking API calls, or ‘await Task.Run(…)’ to do CPU-bound work on a background thread.

How to read a connection string from web.config file in ASP.NET ?

Assume that you have a connectionstring configured in the web.config file of your ASP.NET application and you wish to read it using C# within your application. How to read a connection string from web.config file in ASP.NET ? You can easily do that using the ConfigurationManager class defined in the System.Configuration namespace. 1. Ensure that the System.Configuration assembly is referenced in your project. 2. Add…

How to download a file from a URL using C#?

You can use the WebClient class in C# to download a file. How to download a file from a URL using C#? Here’s a code snippet demonstrating how you can download a file using the instance of the WebClient class in C#.