String Methods of C#
String Methods of C#
Methods of C# string
There are various string methods in C#. Some of them are as follows:
Remove() In C#, Remove() is used for removing the characters from the specified
position of a string. If the length is not specified, then it will remove all the characters
after specified position.
Sample Example
class Geeks {
// Main Method
public static void Main()
{
// define string
String str = "HARISHKANCHAN";
• Output:
• Given String : HARISHKANCHAN
• New String1 : HARI
• New String2 : HARISHKA
Equals() In C#.NET, the Equals() method is a part of the System.String class, and it
is used to compare the contents of two strings to determine if they are equal. The
method returns a Boolean value indicating whether the two strings are equal or not.
For example
Console.WriteLine(replacedString);
Split() The Split() method in C#.NET is a built-in method of the System.String class
that is used to split a string into an array of substrings based on a specified delimiter.
The result is an array of strings containing the substrings.
Example:
Console.WriteLine(fruit);
Console.ReadKey();
Output:
apple
orange
banana
Methods Description
Replace() replaces the specified old character with the specified new character