Declaration of string : String « String « C# / CSharp Tutorial






  1. strings are objects.
  2. string is a reference type.
  1. static string Copy(string str)
  2. int CompareTo(string str)
  3. int IndexOf(string str)
  4. int LastIndexOf(string str)
  5. string ToLower( )
  6. string ToUpper( )

A string is a set of characters enclosed by double quotes. For example,

"this is a test"

is a string.

using System;

class MainClass
{
  static void Main(string[] args)
  {
    string MyString = "Hello World";
    string Path = @"c:\Program Files";
    string Path2 = "c:\\Program Files";

    string Name = "Joe";

  }
}








5.1.String
5.1.1.Declaration of string
5.1.2.String is object
5.1.3.String are immutable
5.1.4.Empty string
5.1.5.Display all the characters in myString using a for loop
5.1.6.Use Indexer to reference chars in a string
5.1.7.Use the Compare() method to compare strings
5.1.8.Use the Concat() method to concatenate strings
5.1.9.Use the addition operator (+) to concatenate strings
5.1.10.Use the Copy() method to copy a string
5.1.11.Use the Equals() method and equality operator to check if two strings are equal
5.1.12.Use the Format() method to format a string
5.1.13.Use the Join() method to join strings
5.1.14.Use the Split() method to split strings
5.1.15.Use the IndexOfAny() and LastIndexOfAny() methods to search for character arrays in a string
5.1.16.Use the Insert(), Remove(), and Replace() methods to modify strings
5.1.17.Use the PadLeft() and PadRight() methods to align strings
5.1.18.Use the Trim(), TrimStart(), and TrimEnd() methods to trim strings
5.1.19.Use the Substring() method to retrieve substrings
5.1.20.Working with Strings
5.1.21.Error; string Is Immutable
5.1.22.Basic String functionality
5.1.23.Is String Interned
5.1.24.Demonstrates the String.Normalize method and the String.IsNormalized method
5.1.25.Whether a string is successfully normalized to various normalization forms.