vimwiki

C# String Methods

Given this string

string str1 = "text";

.ToUpper()

string str2 = str1.ToUpper();

.ToLower()

string str2 = str1.ToLower();

.Length

No parenthesis

int length = str1.Length;

.IndexOf()

int index = str1.IndexOf();


## Access a char in a string

```C#
char str2 = str1[x];

Substring()

Return part of a string

string str2 = str1.Substring(startIndex, lenght);

String concatenation

string str2 = str1 + "other string";

String interpolation

Like f string in python

string str2 = $"this is a string with a {variable}";