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 :
- Immutable strings.
- 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.
- Compare () : its use for compares two strings.
- CompareTo () : its use for compares current instance with another.
- ConCat () : its use for concatenates two or more strings.
- Copy () : Its use For create a new string by copying another.
- Copy To (): Its Copies specified number of characters to an array of Unicode Character.
- EndsWith (): Determines whether the subscript exits at the end of the string.
- Equals (): Determines if two strings are equals.
- IndexOf (): Return the position of the first occurrence of a substring.
- Insert (): Return the new string with a substring inserted at a specified location.
- Join (): join an array of string together.
- LastIndexOf (): Return the position of the Last occurrence of a substring.
- PadLeft (): Left-aligns the string in a field.
- PadRight (): Right-aligns the string in a field.
- Remove (): Delete characters of the string.
- Replace (): Replace all instances of of a character with a new character.
- Split (): Creates an array of string by splitting the string at any occurrence of one or more characters.
- StartsWith (): Determines whether the subscript exits at the beginning of the string.
- ToLower (): Returns the lower-case version of string.
- ToUpper (): Returns the upper-case version of string.
- Trim (): Remove the white space of the string.
- TrimEnd (): Remove a string of characters from the end of the string.
- TrimStart (): Remove a string of characters from the beginning of the string.