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#.


  • Mahesh Chand

    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 interpo...
    Mahesh Chand Feb 24, 2021
  • Mahesh Chand

    Substring in C#

    Learn how to get a C# Substring from a string using String.Substring method in C#.
    Mahesh Chand Dec 14, 2020
  • Mahesh Chand

    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 t...
    Mahesh Chand Oct 13, 2020
  • Mahesh Chand

    How To Format Strings In C#

    C# String Format method formats and converts an object into a string. Learn how to use String.Format() method to format strings in C#.
    Mahesh Chand Sep 29, 2020
  • Mahesh Chand

    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 Tr...
    Mahesh Chand Sep 20, 2020
  • Mahesh Chand

    Split String In C#

    Learn how to split a string in C#. A string can be splitted in C# separated by a character delimiter, string delimiter, and an array of characters.
    Mahesh Chand Mar 03, 2020
  • David Mccarter

    Properly Comparing Strings with Globalization and Performance in .NET

    In Microsoft .NET there are many ways to compare strings. In this article, I will show a proper way to compare Strings with Globalization and Performance in .NET.
    David Mccarter Nov 12, 2019
  • Jin Vincent Necesario

    Playing With C# Strings Instance Methods

    String manipulation is one of the favorite subjects of developers when learning C#. In this article, we are going to focus on string instance methods. We might not cover every method, but most of t...
  • Mahesh Chand

    How To Replace Characters In A C# String

    In this article, you will learn how to replace a substring in a C# string.
    Mahesh Chand Sep 26, 2019
  • Mahesh Chand

    6 Effective Ways To Concatenate Strings In C#

    Code examples of the most effective ways to concatenate strings in C#.
    Mahesh Chand Sep 25, 2019
  • Mahesh Chand

    How To Compare Strings In C#

    Code examples of compare strings in C# using String.Equals, String.Compare, String.CompareTo() method, and StringComparer.
    Mahesh Chand Sep 25, 2019
  • Mahesh Chand

    Most Common C# String Code Examples

    C# String class represents a string data type. This tutorial explains strings in C# and how you can use strings in your .NET applications.
    Mahesh Chand Sep 25, 2019
  • Mahesh Chand

    How To Remove Specific Characters From C# String

    How to use string Remove method to remove characters from a string at specified positions.
    Mahesh Chand Sep 23, 2019
  • Mahesh Chand

    Implementing C# String Array

    A C# string array is an array of strings. Here are different examples of implementing String Array in C#. C# String Array code examples.
    Mahesh Chand Sep 21, 2019
  • Mahesh Chand

    Convert Byte Array To String In C#

    Learn to convert a C# byte array to string in C# and .NET Core. Code example included.
    Mahesh Chand Sep 17, 2019
  • Mahesh Chand

    Add, Remove, Replace String In C#

    Code examples to add strings in C#, remove string in C#, and replace string in C#.
    Mahesh Chand Aug 23, 2019
  • Mahesh Chand

    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(...
    Mahesh Chand Jun 05, 2019
  • Mahesh Chand

    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.
    Mahesh Chand Jun 03, 2019
  • Mahesh Chand

    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
    Mahesh Chand May 28, 2019
  • C# Curator

    C# StringBuilder

    C# StringBuilder is useful for concatenating multiple strings. The code examples demonstrates how to use a StringBuilder in C#.
    C# Curator May 09, 2019
  • Prakash Tripathi

    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.
    Prakash Tripathi Mar 31, 2019
  • Hari Shankar

    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 s...
    Hari Shankar Jan 17, 2019
  • Mahesh Chand

    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 Str...
    Mahesh Chand Oct 22, 2018
  • Mahesh Chand

    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#.
    Mahesh Chand Sep 19, 2018
  • Kailash Chandra Behera

    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.
  • View More