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

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 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. How to Count Occurrences of a Character Inside a String in C#There are 3 main methods that can be used to calculate the number of occurrences of a character inside a string variable in C#, the linq method, the String.Split() function and the foreach loop. How to Slice An Array in C#There are 3 main methods that can be used to slice an array in C#, the Linq method, the ArraySegment class, and the extension function method. How to Print Array in C#There are 3 main methods that can be used to print an array of strings in C#, the String.Join() method, the ForEach() function, and the foreach loop method. How to Iterate Through a List in C#There are 3 main methods that can be used to iterate through a list in C#, the for loop, the foreach loop, and the Lambda expressions. How to Generate Random Alphanumeric Strings in C#There are 3 main methods that can be used to generate random alphanumeric strings in C#, the Random class, the LINQ method, and the RNGCryptoServiceProvider class. Final Keyword in C#There are 2 different keywords in C# that are equivalent to the final keyword in Java, the sealed keyword for classes and functions, and the readonly keyword for the fields. How to Get File Size in C#The FileInfo.Length property can be used to get the size of a file in C#. How to Download Image in C#There are 3 main methods that can be used to download an image in C#, the WebClient.DownloadFile() function, the Bitmap class, and the Image.FromStream() function. How to Create DataTable in C#The DataTable class can be used to create a data table in C#. How to Convert Int to Hex in C#The ToString() function can be used to convert an integer value to a hexadecimal string and the Convert.ToInt32() function can be used to convert a hexadecimal string to an integer value in C#.