ToLower () is used to change the string to lowercase, note the immutable nature of the string, and need to reassign the value to another string variable.
s = S.tolower (); // strings are immutable and need to be re-assigned after conversion, not just s. ToLower ();
This allows the user's input to be case insensitive, such as a captcha.
ToUpper () is used to capitalize all strings, similar to the above.
Trim () can be used to remove spaces on both sides.
string " a b c "; = S1. Trim (); // used to remove spaces on both sides of a string Console.WriteLine (S1);
Equals () is used to compare strings, which contain multiple overloaded methods.
string " Admin " ; string " Admin " ; // the comparison of ignoring case is StringComparison.OrdinalIgnoreCase Console.WriteLine (S1. Equals (s2,stringcomparison.ordinal));
String. Format () to generate a new string with placeholders and formats.
string string. Format (" I call {0}, I {1} years old ""www"); Console.WriteLine (s1);
2018.08.04
Novice C#string Class common functions of learning 2018.08.04