String class in C# (Methods and properties)

String Methods
  1. Substring(): Returns a new string that is a substring of the current string.
  2. Concat(): Concatenates two or more strings into a new string.
  3. Trim(): Removes leading and trailing white spaces from the string.
  4. Replace(): Replaces all occurrences of a specified character or string with another character or string.
  5. ToLower(): Converts all characters in the string to lowercase.
  6. ToUpper(): Converts all characters in the string to uppercase.
  7. Contains(): Returns a boolean indicating whether a specified substring is present in the string.
  8. IndexOf(): Returns the zero-based index of the first occurrence of a specified substring.
  9. Split(): Splits the string into an array of substrings based on a specified delimiter.
  10. StartsWith(): Returns a boolean indicating whether the string starts with a specified prefix.
  11. EndsWith(): Returns a boolean indicating whether the string ends with a specified suffix.
  12. Join(): Joins an array of strings into a single string using a specified separator.
  13. PadLeft(): Pads the string on the left with a specified character or space to a specified total length.
  14. PadRight(): Pads the string on the right with a specified character or space to a specified total length.
  15. Compare(): Compares two strings and returns an integer that indicates their relative position in the sort order.
  16. ToCharArray(): Converts the string to a character array. 
Properties:
  1. Length: Gets the number of characters in the string.
  2. Chars[index]: Gets the character at the specified index in the string.
  3. IsNullOrEmpty: Gets a value indicating whether the string is null or an empty string.
  4. IsNullOrWhiteSpace: Gets a value indicating whether the string is null, empty, or consists only of white-space characters.
  5. First: Gets the first character of the string (C# 8.0 and later).
  6. Last: Gets the last character of the string (C# 8.0 and later).
  7. [int index]: Gets or sets the character at the specified index in the string.
  8. Chars: Gets an array containing the characters in the string.
  9. Original: Gets the original string before any transformations (C# 8.0 and later).
  10. Empty: Represents an empty string. This field is read-only.

Comments

Popular posts from this blog

SQL Server Queries

Simple calculator (Console application/Java)