Categories
.NET .NET 10 ASP.NET Core Aspire Automation Azure Blazor C# CLI Code Desktop Developer Getting Started Linux macOS Mobile Visual Studio VS Code Web What's New Windows

Using C# Ignored Directives: A Guide for Programmers

C# – Preprocessor Directives are highly useful for writing code that can be compiled conditionally, depending on factors like the target framework, target platform, or build configuration.

For example:

#if NET9_0_OR_GREATER
// The code within this block will execute only on .NET 9 or higher
#endif

#if ANDROID
// The code within this block will execute only on the Android OS
#endif

#if DEBUG
// The code within this block will execute only in Debug mode
#endif

C# – Ignored Directives have a similar syntax but are ignored by the compiler because they are for tooling.

The real purpose of this feature is to execute a C# source file directly from the CLI. It doesn’t need a project file. Now, even the plain console app requires a project file, despite the much-simplified top-level statements feature.

Categories
.NET .NET 8 .NET MAUI Desktop Developer Preview Visual Studio Windows

.NET 8 SDK – Visual Studio 2022 Compatibility

Today being the second Tuesday of the month marks the occurrence of Patch Tuesday, signifying the release of a new set of updates.

The second preview for .NET 9 is now available in the Preview channel, while Quality updates have been made accessible in the stable channel.

Quite like the SDK, Visual Studio 2022 has also received updates. The latest update includes VS2022 17.10.0 Preview 2.0 and 17.9.3 in the Stable channel.

Note: The stable version 17.9.3 release incorporates .NET MAUI 8.0.7 (SR2) workload update, which was previously available as a NuGet package update.