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 9 .NET MAUI Android Blazor C# Code Desktop Developer Hybrid iOS Issue macOS Mobile Preview Quick Fix Web Windows

.NET MAUI 9 Preview 5 XAML Compilation Issue: Resolving Content Property Error

After the installation of .NET MAUI 9 Preview 5, an XAML compilation (XAMLC) issue has arisen.

In general, it is not necessary to explicitly specify the default property such as Content, Children, etc.

The Content is the default property for Page, View, and Toolkit’s Popup, and this XAMLC issue is about the Content property.