...

/

Built-in String and Array Functions

Built-in String and Array Functions

Learn to use popular built-in functions related to strings and arrays in C#.

Built-in functions for strings

C# provides various built-in functions for dealing with strings. These functions are collectively called string methods.

Note: All string methods return a new string without changing the original one.

There are numerous tasks related to strings that make it easy for programmers to perform routine tasks. This section will provide examples and results of some commonly used string methods.

The methods related to case change

These methods change the letter case of the text stored in a string (say, from lowercase to uppercase). Let’s use an example program to explore case changes.

  • The ToLower() method converts all characters in a string to lowercase.
  • The ToUpper() method converts all characters in a string to uppercase.
Press + to interact
class Test
{
static void Main()
{
System.Console.WriteLine("EDUCATIVE".ToLower());
System.Console.WriteLine("educative".ToUpper());
}
}

The search-related functions

These functions search for the occurrence of text in a string. Let’s use an example program to explore searches.

  • The Compare() compares two strings and return 00 ...

Access this course and 1400+ top-rated courses and projects.