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 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. How to Add Newline to String in C#There are 2 main methods that can be used to add a new line to a string in C#, the escape character, and the Environment.NewLine property. 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 Make HTTP POST Web Request in C#There are 3 main methods that can be used to make an HTTP POST Web Request in C#, the WebClient class, the HttpWebRequest class, and the HttpClient class. 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. Case Insensitive Contains String Function in C#There are two main methods that can be used to create a case insensitive contains (string) function in C#: the CultureInfo.IndexOf() function and the string.IndexOf() function. C++ Map<T1, T2> Equivalent in C#The SortedDictionary<Tkey, Tvalue> and the Dictionary<Tkey, Tvalue> classes in C# can be used in place of the map<key, value> in C++. How to Split String to List in C#This tutorial discusses different methods for splitting a string into a list of strings in C#, discussing how each method works and its use cases. How to Encrypt and Decrypt a String in C#The AesManaged class can be used to encrypt and decrypt a string in C#. How to Copy a Object in C#There are 2 main methods that can be used to create a separate copy of an object in C#, the MemberWiseClone() function, and the parameterized constructor method. How to Copy a List in C#In this article, we will explore different techniques for copying lists in C# and discuss their use cases, advantages, and implementation details. How to Append to Array in C#There are 2 main methods that can be used to resize an array in C#, the list.Add() with the list.ToArray() functions, and the Array.Resize() function. Multiple Case Switch Statement in C#There are 2 syntaxes that can be used to create a multiple case switch statement in C#, the conventional switch statement and the range-based switch statement. How to Read and Write to a File in C#There are 4 main methods that can be used to read data from and write data to a file in C#, the File.WriteAllText() function, the File.ReadAllText() function, the StreamWriter class, and the StreamReader class. How to Encode and Decode a Base64 String in C#The Convert class can be used to encode a standard string to a base64 string and decode a base64 string to a standard string in C#. How to Call Constructor From Another Constructor in C#The this keyword can be used to call one constructor from another constructor of the same class in C#. Float vs Double vs Decimal in C#The difference between the float, double and decimal data types in C# is described below. How to Validate Email Address in C#There are 2 main methods that can be used to validate an email address in C#, the MailAddress class and the EmailAddressValidator class. How to Get the First Character of a String in C#There are several methods that can be used to get the first character of a string variable in C#. How to Get Relative Path of a File in C#There are 2 main methods that can be used to generate the relative path of a file in C#, the Path class, and the resources.resx file.