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

Abstract Function vs Virtual Function in C#An abstract function does not provide any definition of itself, while a virtual function has a default definition in C#. Thread vs Task in C#The Thread class creates an actual OS thread while the Task class creates a task that asynchronously executes in the thread pool. How to Write to the Output Window in C#There are 3 main methods that can be used to write to the debug window of the Microsoft Visual Studio IDE in C#, the Debug.Write(), the Debug.WriteLine(), and the Debug.Print() functions. How to Wait for a Thread to Finish in C#There are two main methods to wait for the completion of threads in C#, the Task.WaitAll() and the Thread.Join() functions. How to Remove First Character From String in C#There are two main methods that can be used to remove the first character from a string in C#, the String.Remove() method and the String.Substring() method. We can also achieve the same result using String Interpolation and LINQ. How to Pass Object by Reference in C#By default, all the value type variables are passed by value and all the reference type variables are passed by reference to a function in C#. How to Keep Console Open in C#There are 4 main methods that can be used to keep the console of visual studio IDE open in C#, the Console.ReadLine() method, the Console.Read() method, the Console.ReadKey() method, and the Ctrl + F5 shortcut. How to Get All File Names in a Directory in C#There are two main methods that can be used to get the file names of all the files inside a directory in C#, the Directory.GetFiles() function and the DirectoryInfo.GetFiles() function. How to Format a String to Currency in C#There are two main methods that can be used to format a string to currency format in C#, the String.Format() and the ToString() functions. How to Delete Object in C#We can delete the object of a user-defined class by assigning a null value to it in C#. How to Create New Instance From Type in C#This tutorial will discuss the methods of creating a new instance of a given data type at runtime in C#. How to Convert Long to Int in C#There are 3 main methods that can be used to convert a long variable to an integer variable in C#, the type casting method, the Convert.ToInt32() function, and checked and unchecked keywords. How to Check Palindrome String in C#There are two main methods that can be used to check whether a string is a palindrome or not in C#, the String.Substring() method and the LINQ method. How to Append to Text File in C#There are three main methods that can be used to append to a text file in C#, the File.AppendAllText() method, the StreamWriter class, and the File.AppendText() How to Close Form in C#This tutorial will explore different methods that can be used to close a form in C#. How to Get Executable Path in C#There are 3 main methods that can be used to get the executable path of our program in C#, the Assembly class, the AppDomain class, and the Path class. How to Check if Process Is Running in C#There are two main methods that can be used to check if a process is running in C#, the Process.GetProcessByName() function, and the Process.GetProcessById() function. How to Repeat String X Times in C#In this article, we will explore five different methods to repeat a string x times in C# and discuss when to use each one. How to Remove Duplicates From List in C#There are two main methods that can be used to remove duplicate elements from a list in C#, the HashSet method, and the LINQ method. How to Parse CSV File in C#There are two main methods that can be used to parse a CSV file in C#, the TextFieldParser class, and the FileHelpers library. How to Implement Multiline Label in C#There are two main methods that can be used to create a multiline label in C#, the Label.AutoSize property, and the Panel method. How to Convert String to Char in C#There are four main methods that can be used to convert string to char in C#, char.Parse(), string[index], string.ToCharArray(), and the LINQ method. How to Format Datetime in C#This tutorial demonstrates how to convert a datetime variable to a formatted string using the ToString and String.Format function How to Exit a Function in C#In this tutorial, learn the different methods of exiting a function in C# with examples. Use the break, continue, goto, return, and throw exception statements.