in C#, A predefined reference type known as String. strings represents a sequence of character and also you can say string as array of characters. the string keyword is an alias for the System.String class.

C# support two type of string :

  1. Immutable strings.
  2. Mutable strings.

A feature known as regular expressions its use for complex string manipulations and pattern matching in c#.

We can create immutable string by using string and string object with these ways.

  • By assigning string literals
  • By copy from one object to another
  • By Concatenating two object
  • By retrieving a property or calling a method that returns a string
  • By using ToString method

String class properties :

  • Chars – it is use for to Get the Char object at a specified position in the current String object.
  • Length – it is use for to Get the number of characters in the current String object.

STRING METHOD : String class object are immutable , we can’t modify characters  without method.

  1. Compare () : its use for compares two strings.
  2. CompareTo () : its use for compares current instance with another.
  3. ConCat () :  its use for concatenates two or more strings.
  4. Copy () : Its use For create a new string by copying another.
  5. Copy To (): Its Copies specified number of characters to an array of Unicode Character.
  6. EndsWith (): Determines whether the subscript exits at the end of the string.
  7. Equals ():  Determines if two strings are equals.
  8. IndexOf (): Return the position of the first occurrence of a substring.
  9. Insert (): Return the new string with a substring inserted at a specified location.
  10. Join (): join an array of string together.
  11. LastIndexOf (): Return the position of the Last occurrence of a substring.
  12. PadLeft (): Left-aligns the string in a field.
  13. PadRight (): Right-aligns the string in a field.
  14. Remove (): Delete characters of the string.
  15. Replace (): Replace all instances of of a character with a new character.
  16. Split (): Creates an array of string by splitting the string at any occurrence of one or more characters.
  17. StartsWith ():  Determines whether the subscript exits at the beginning of the string.
  18. ToLower (): Returns the lower-case version of string.
  19. ToUpper (): Returns the upper-case version of string.
  20. Trim (): Remove the white space of the string.
  21. TrimEnd (): Remove a string of characters from the end of the string.
  22. TrimStart (): Remove a string of characters from the beginning of the string.


Leave a Reply

Your email address will not be published. Required fields are marked *