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#.

C# Compiler Error – CS4011 ‘await’ requires that the return type ‘{

In this blog post, you’ll learn more about the C# Compiler Error – CS4011 and the related message description C# Compiler Error Code CS4011 C# Compiler Description for the Code :CS4011 ‘await’ requires that the return type ‘{0}’ of ‘{1}.GetAwaiter()’ have suitable ‘IsCompleted’, ‘OnCompleted’, and ‘GetResult’ members, and implement ‘INotifyCompletion’ or ‘ICriticalNotifyCompletion’

C# Compiler Warning – CS8669 the annotation for nullable reference ty

In this blog post, you’ll learn more about the C# Compiler Warning – CS8669 and the related message description C# Compiler Warning Code CS8669 C# Compiler Description for the Code :CS8669 The annotation for nullable reference types should only be used in code within a ‘#nullable’ annotations context. Auto-generated code requires an explicit ‘#nullable’ directive in source.