Strings. Overview.

String is a list (or sequence) of characters in a specific order. The entire sequence of characters is treated as a single object.

A character is anything you can type on the keyboard with a single keystroke (letter, number, reverse slash or some other character).
Strings can have spaces: "Hello world!".
An empty string is a string that has 0 characters.
C sharp accepts as strings everything that is written in quotes (""), string is of type string.

Important to remember: strings in C# are immutable.

You can write a new value to a string using the input operator:
string s = Console.ReadLine(); 
You can also simply assign a string value to the variable, for example:
string s = "C sharp"; 
You can define the length of a string like this:
int n = s.Length;


String comparison. Strings can be compared to each other just like numbers. You can determine which of the lines is greater, which is less.

When comparing strings, character codes are compared. There are dozens, if not hundreds, of character encodings. The easiest way to understand this concept is to understand one of the simplest, ASCII (you can read about it here) . 
It is necessary to understand that in modern encodings both Russian and English letters are arranged in alphabetical order, the numbers also go from smaller to larger. 
For example, in the ASCII code table, the code for the English letter 'A' - 65, letters 'a' - 97, digit '0' has code 48. Russian letters are located in the extended part of the ASCII code table (numbers from 128 to 255). Capital letters come before (i.e. have a smaller code) than lowercase letters.
In most of the encoding tables used, the patterns are the same, lowercase letters are later than uppercase letters, numbers are earlier than letters, and Russian letters are later than English ones.
When comparing characters or strings, C# converts the characters to their respective ordinal values ​​and then compares from left to right. 

For example: "locomotive" < "steamboat", because the words differ in the fifth letter and "in" < "x".

When entering a string, you can immediately divide it into parts by any separator.
We've done this before when we entered multiple numeric variables on the same line. We used the Split() method to split a string into parts. By default, it separates strings into substrings by space.
Using this method, you can split the string into parts, for example, by spaces. And write each part of the string into a separate variable.
Example:
string[] S = Console.ReadLine().Split();
In the example, when entering two words separated by a space, the first word is stored in the zero element of the s[0] array, the second - in the second s[1].

If you need to use several characters as separators, you can specify them separated by commas:
 
 string[] S = Console.ReadLine().Split(new[] { ' ', '\n' });
 If there can be several consecutive spaces in the input string, then spaces can also appear in the final array, to exclude this, you need to add a parameter:
string[] S = Console.ReadLine().Split(new[] { ' ', '\n' }, StringSplitOptions.RemoveEmptyEntries);
If you need to use substring delimiters:
string[] S = Console.ReadLine().Split(new[] { "\\r\\n", "\r", "\n", "" }, StringSplitOptions.RemoveEmptyEntries);

Strings can be added together using the "+" sign. This operation is called string concatenation or concatenation
For example, 
string s = "Hi,";
string s1 = "world";
Console.WriteLine(s + s1);
The screen will display the phrase "Hello world" (without quotes).
 

Referencing row indices
Each character in a string has a number (called index), and indexing in the C# programming language starts from zero. That is, the first character has index 0, the second - 1, and so on.
String characters can be accessed by indexes, which are indicated in square brackets s[i].
 
Example 
String S H e l l o
Index S[0] S[1] S[2] S[3] S[4]

Important!
When accessing a string element at index i, the type s[i] is not string but char. This means that this is not a string, but a character that corresponds to some integer in the character code table. In particular, when you add two elements of type char , you get an integer - the addition of the codes of these elements. However, if you display s[i], the i-th character of the string will be displayed, not the number corresponding to it. 

Because a character can be accessed by index, a variable loop can be used to iterate over all characters, which will take possible index values. For example, a program that displays all the character codes of the string s would look like this:
for (int i = 0; i < s.Length; i++)
{
  Console.WriteLine(s[i]);
    Console.WriteLine(Convert.ToInt32(s[i]));
}

Program notes:
1) s.Length finds the length of a string. The index of the first character is 0 and the index of the last is s.Length-1. The loop variable i will just take values ​​sequentially from 0 to 
s.Length-1;
2) in each line, the symbol itself will be displayed first, and then its code, which can be obtained through the  Convert.ToInt32();
method
The same enumeration can be written shorter:


foreach (char c in s)

    Console.WriteLine(c);
    Console.WriteLine(Convert.ToInt32(c));
}

In this snippet, the loop header loops through all  s characters, placing one by one into the variable c.
The peculiarity of C# when working with strings is that strings are immutable objects. In other words, we cannot change individual characters of a string.
For example, the following statement will not work:
s[5]=" ";