C# Strings
String class in .NET and C# represents strings. On this page, there is a list of code examples and tutorials related to strings in C#. Learn string concatenation, trim strings, replace strings, remove strings, and effective use of strings using StringBuilder class in C#.


  • C# Concatenate Strings

    The code examples demonstrate how to concatenate strings in C# including insert string, append string, and merge strings in C# using the .NET String class and its methods.
  • String In C#

    C# String class represents a string data type. String type is probably the most used data types in .NET. In this tutorial, learn how to work with Strings in C#.
  • StringBuilder and String Concatenation

    C# String Builder represented by the StringBuilder class in c# is used to concatenate strings in C# and provides string modifications methods including StringBuilder.Append(), StringBuilder.Remove(),
  • Compare Strings In C#

    The code examples compare strings in C# using String.Equals, String.Compare, String.CompareTo() method, and StringComparer. String compare in .NET and C# .
  • C# String To Byte Array

    The Encoding.GetBytes() method converts a string into a byte array in C#. This article includes a code example of how to convert a C# string into a byte array.
  • Convert Byte Array To String In C#

    This code snippet is example of how to convert a C# byte array to a string in .NET Core.
  • Understanding String Interpolation In C#

    C# string interpolation is used to format and manipulate strings. This feature was introduced in C# 6. Using string interpolation, we can use objects and expressions as a part of the string interpolat
  • C# String Array

    A string array is an array of strings. Here are different examples of implementing String Array in C#. C# String Array code examples.
  • StringCollection in C#

    StringCollection is a collection of strings. In this article, learn how to take advantages of StringCollection methods and properties to manage a collection of strings. StringCollection class
  • Split String In C#

    Learn different ways to Split Strings in C#. A string can be splitted in C# separated by a character delimiter, string delimiter, and an array of characters.
  • C# StringBuilder

    C# StringBuilder is useful for concatenating multiple strings. The code examples demonstrates how to use a StringBuilder in C#.
  • Reverse A String In Various Ways Using C#

    This article explains different ways to reverse a String in C#. Here we explored the possible ways using both Iterative and Recursive methodologies without using Reverse method of .NET framework.
  • SubString In C#

    A Substring in C# is a contiguous sequence of characters within a string. In this code example, learn how to get a C# Substring using String.Substring method using C# and .NET Core.
  • Use Of String.Format() To Format Strings In C#

    In this article, you will learn how to format strings in C#. C# String Format method converts an object into a string. C# sample code formats strings and other data types to string using C# in .NET Co
  • Generate Random Number And Random String In C#

    The Random.Next() method returns a random number in C#. The Random class's RandomByte and RandomDouble method returns a random byte and and a random double integer. The code examples show how to g
  • Verbatim String Literals

    Other than the regular string literals, C# supports what is called as Verbatim string literals.Verbatim string literals begin with @" and end with the matching quote. They do not have escape sequ
  • Add, Remove, Replace Strings In C#

    This code snippet shows how to add, remove and replace strings in C# and .net core. Insert method in C#, Remove method in C#, Replace method in C#, Split method in C#.
  • Padding Strings In C#

    This code snippet shows how to pad strings in C# and .net core. Padding in string is adding a space or other character at the beginning or end of a string. String class has String.PadLeft() and String
  • Trim String in C#

    String.Trim(), String.TrimStart(), and String.TrimEnd() methods provide trim string functionality in C# and .NET. The Trim method removes white spaces from the beginning and endof a string. The TrimE
  • Uppercase and Lowercase Strings in C#

    C# String has ToUpper() and ToLower() methods to convert a string to uppercase and lowercase. This sample code demonstrates how to convert a string into lowercase string or uppercase string in C#.
  • Differences Between Text, Stream, String and Binary Data

    This article provides an overview of the differences between Text, Stream, String and Binary Data and related classes to stream.
  • Finding Directories With Regular Expressions

    This article provides an example of using a regular expression to search a directory and determine a file type. C# Regular Expressions
  • Checking Birthday By Regular Expression

    This example tries to check birthday using Regular Expression
  • Convert A String To Title Case In C#

    There is no direct method like ToUpper(), ToLower() for Title Case. But using CultureInfo and TextInfo classes we can do Title case of a string.
  • Copy And Concatenate String In C#

    This code snippet shows how to copy and concatenate strings in C# and .net core. The Concat method adds strings (or objects) and returns a new string. Using Concat method, you can add two strings, two
  • View More