Practical solutions

C# Howtos How-To Guides

Solve the problem. Keep building. Collection of C# how-to articles

Find the answer you need

Browse practical solutions, grouped by the task you're working on.

__COUNT__ entries on this page

How to Do Percentage Calculation in C#Learn how to calculate a percentage of a value, increase a value, and decrease a value in C#. How to Reset Timer in C#Restart a one-shot System.Timers.Timer in C# with Stop and Start, and learn how AutoReset controls recurring elapsed events. How to Check Whether a File Exists in C#Learn how to check whether a file exists in C# with File.Exists and how to use the result safely. How to Convert String Array to Int Array in C#In this guide, we will learn how to convert a string array to an int array in C#. How to Exit Console Application in C#Choose between returning from Main and terminating a C# console application immediately, with clear exit-code and cleanup behavior. How to Stop a Thread in C#In this article, I'll explain how to start and stop a thread in C#. Carriage Return in C#In this article, we'll learn carriage return in a string in C#. How to Minimize Applications in the System Tray in C#This article explains how to minimize a Windows Forms application to the system tray with NotifyIcon in C#, hiding the form and restoring it from the tray icon. How to Read a CSV File and Store Its Values Into an Array in C#This how-to article shows different methods to read a CSV file and store its values into an array in C#. It introduces methods like OpenRead(), ReadLine() and TextFieldParser How to Add a Newline to a String in C#Learn three ways to add a line break to a C# string: use ` `, `Environment.NewLine`, or replace a marker in existing text. How to Write to an Excel File in C#Learn how to write to an Excel file in C# How to Initialize a List of Tuples in C#This article explores several approaches to efficiently initialize a list of tuples in C#. HTML to PDF in C#Convert an HTML string to an A4 PDF in C# with HtmlRenderer.PdfSharp. How to Check if TextBox Is Empty in C#Check a Windows Forms TextBox with String.IsNullOrEmpty() or TextBox.Text.Length, and learn when whitespace-aware validation is needed. C# Convert Int to CharThis tutorial teaches how to cast int to char in C#. How to Get Selected Value of a ComboBox in C#Learn how to read the selected item, displayed text, or bound value from a Windows Forms ComboBox in C#. How to Open a PDF File in C#Learn how to launch a PDF in its default viewer or extract its text with C#, and how to assess WinForms viewer controls. How to Implement OCR in a C# ProjectLearn how to add Tesseract or IronOCR to a C# project and recognize text in an image. How to Make a Delay Timer in C#This article introduces how to make a delay timer in C#. It includes four different methods: Thread.Sleep(), Task.Delay(), System.Timers.Timer, and System.Threading.Timer. How to Convert a JSON String to a JObject in C#Parse JSON text into a JObject in C# with Newtonsoft.Json, read nested values, handle parsing errors, and serialize changes. How to Add List to Another List in C#Learn how to add one list to another in C# How to Convert Values to Int in C# with Cast, Parse, or ConvertChoose a C# integer conversion based on whether your input is numeric, integer text, or another supported value. How to Obfuscate Your Code in C#Learn how C# obfuscation transforms managed assemblies, what common techniques do, and how to evaluate their limits. How to Initialize a Byte Array in C#Learn how to create a byte array of a specific length in C#, set its values, and copy raw bytes.