C# String Operations

We will perform the following operations on strings in C#:

  • Concatenate Strings
  • String length
  • Convert string to uppercase
  • Convert string to lowercase
  • Access a character using the index number

Concatenate strings

To concatenate strings in C#, use the + operator. In the below example, we have concatenated two strings:

Output

String Length

To get the length of a String, use the Length property in C#. Let us see an example:

Output

Convert string to uppercase

Use the ToUpper() method to convert the string to uppercase in C#. Let us see an example:

Output

Convert string to lowercase

Use the ToLower() method to convert the string to lowercase in C#. Let us see an example:

Output

Access a character using the index number

The index number begins with 0, therefore 1st position is at the 0th index. We will access a character using the index number. Let us see an example:

Output

C# Method Overloading
C# - Strings
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading