This episode covers desktop and cross-platform application development: .NET MAUI for Android, iOS, and Windows, the basics of WPF and WinForms for Windows, interoperability with native libraries, and packaging and distribution of desktop applications.

Up to episode 20 you worked on the server side. Now we look at the equally important side: applications that users run on desktops and mobile devices. C# offers a complete set of options for this.
A single C# codebase can run on Android, iOS, and Windows through .NET MAUI, while WPF and WinForms remain the primary choices for mature Windows applications. They all share the same language, runtime, and ecosystem.
Episode 21 covers .NET MAUI, the basics of WPF and WinForms, interoperability with native libraries, and packaging and distribution of desktop applications.
.NET MAUI (Multi-platform App UI) lets one C# project produce applications for Android, iOS, macOS, and Windows:
dotnet new maui -n AplikasiKantinThe dotnet new maui -n AplikasiKantin command creates a project with a shared structure: XAML files for the interface and C# for logic. The UI is defined once with XAML and rendered natively on each platform:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<VerticalStackLayout Padding="30" Spacing="10">
<Label Text="Menu Kantin" FontSize="32"
HorizontalOptions="Center" />
<Button Text="Lihat Menu"
Clicked="OnLihatMenuClicked" />
</VerticalStackLayout>
</ContentPage>The C# code-behind handles interactions:
public partial class MainPage : ContentPage
{
public MainPage() => InitializeComponent();
private void OnLihatMenuClicked(object sender, EventArgs e)
{
DisplayAlert("Menu", "Nasi Goreng, Sate, Es Teh", "OK");
}
}DisplayAlert shows a native dialog. With this model, one codebase serves many platforms without rewriting the interface.
WPF is the most mature desktop framework for Windows, with vector-based rendering and theme support:
dotnet new wpf -n AplikasiWindowsWPF also uses XAML, but targets Windows only. Window is the main container, and layouts like Grid and StackPanel arrange UI elements. WPF is the choice for enterprise Windows applications that need complex interfaces.
WinForms is the simpler approach: drag-and-drop controls in a designer, lightweight, and ideal for internal tools:
var form = new Form { Text = "Kalkulator", Width = 300, Height = 200 };
var tombol = new Button { Text = "Hitung", Location = new Point(20, 20) };
tombol.Click += (s, e) =>
MessageBox.Show("Hasil: 42", "Kalkulator");
form.Controls.Add(tombol);
Application.Run(form);The window and button creation pattern above uses constructors and event handlers — code you've known since the start of this series. For rapid development of internal tools, WinForms is still the winner.
Desktop applications often need to call native libraries like Win32 or third-party DLLs. P/Invoke (Platform Invoke) does this directly:
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
static extern int MessageBox(IntPtr hWnd, string teks, string judul, uint tipe);
var hasil = MessageBox(IntPtr.Zero, "Halo dari native", "P/Invoke", 0);
Console.WriteLine($"Kode hasil: {hasil}");DllImport("user32.dll") declares a native Windows function so it can be called from C#. With the same pattern, you can call C libraries on Linux or macOS — this is .NET's gateway to the native ecosystem.
When calling native code, pay attention to calling conventions and marshaling of data types. Pointers use IntPtr, strings use the correct CharSet, and native structs are marked with [StructLayout]. Getting this wrong causes mysterious crashes — always test on the target platform.
For distribution, you can package the application as an installer or a self-contained executable:
dotnet publish -c Release -r win-x64 --self-contained -o publishThe dotnet publish -c Release -r win-x64 --self-contained command produces a folder containing the application and the .NET runtime together — users don't need to install .NET separately. This output can be wrapped in an installer with MSIX, WiX, or Inno Setup for WPF.
For MAUI, distribution follows each platform's store: Google Play for Android, the App Store for iOS, and MSIX or the store for Windows. Code signing is required for official publication.
Key takeaways:
In the final episode 22 we look ahead: future trends and stable modern features — records, pattern matching, and nullable reference types, Native AOT and source generators, modern .NET 8 and 9 features and their roadmap, and strategies for keeping your C# skills relevant.