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

The Difference Between Environment.Newline and Discover the key differences between Environment.Newline and "\n" in C How to Convert Int to Float in C#Learn how to convert an int to a float in C How to Write a Multiline String Literal in C#This article explores how to write multiline string literals in C How to Get the Length of an Array in C#Discover how to get the length of an array in C Exponent in C#This article explores the exponent operator in C Double Question Mark in C#This article explores the double question mark operator in C How to Shuffle a List in C#Unfortunately, there is no pre-defined method available for shuffling a list in C#. So, we have to rely on self-generated code for shuffling a list in C#. How to Return Multiple Values From a Function in C#There are 3 main methods that can be used to return multiple values from a function in C#, using array as the function return-type, using a class or a structure as the function return-type, and using a Tuple<T1,T2> class as the function return-type. How to Get Local IP Address in C#There are 4 main methods that can be used to get local IP address in C#, the Dns.GetHostEntry() function, the Socket.LocalEndPoint property, the Linq method and the NetworkInterface class. Difference Between Struct and Class in C#The structures are value type variables that reside in the stack while the classes are reference type variables that reside in the heap. How to Pass a Function as a Parameter in C#There are 2 main methods that we can use to pass a function as a parameter inside another function in C#, the func<> delegate, and the Action<> delegate. How to Resize an Image in C#There are 2 main methods that can be used to resize an image in C#, the Bitmap class constructor and the graphics.DrawImage() function. How to Pause Console in C#There are 3 main methods that can be used to pause the console of visual studio in C#, the Console.ReadLine() function, the Console.ReadKey() function, and the Ctrl + F5 shortcut. How to Generate a Random Float in C#This article will discuss the methods on how to generate random float values in C#. How to Declare a Multidimensional List in C#Unfortunately, there is no built-in method to declare a multidimensional list in C#. To achieve this objective, we can use one of the following user-defined approaches. the list of lists, the list of classes, and the list of tuples. How to Declare a Global Variable in C#Unfortunately, there is no built-in method to declare a truly global variable in C#. To achieve this objective we have to rely on some user-defined approaches. How to Create an Inline Function in C#There are 3 main methods that can be used to create an inline function in C#, by using lambda expressions, by using lambda statements, and by using local functions. How to Check if an Array Contains a Value in C#This article will guide you through the various methods available in C# to check for an element inside an array. SQL Insert Query in C#There are 2 main methods that can be used to insert records to a database in C#, the direct query method and the parameterized query method. lock Statement in C#The lock statement specifies that the specified section of code cannot be accessed by multiple threads at the same time in C#. How to Get the Size of an Array in C#There are 2 main methods that can be used to get the size of an array in C#, the Array.Length property, and the Array.Rank property. How to Get and Set in C#The get and set accessors are used to input and output data into a private field in C#. How to Convert List<string> to String in C#There are 3 main methods that can be used to convert a List<string> to a string variable in C#, the LINQ Aggregate method, the String.Join() function and StringBuilder class. Enum Strings in C#There are 3 main methods that can be used to create an enumeration of strings in C#, the extension function, the constant variables method, and the ToString() function.