Once I have seen many colleagues write classes similar to the Stringhelper class (which encapsulates some common string manipulation methods), I have written similar classes, encapsulating strings, comparing strings, judging strings, and other commonly used string manipulation methods. Now that most of these methods are redundant, Microsoft has provided many common operations for strings and is more powerful and easier to use than it writes. Some common methods are listed below:
String input = ", ABCDE,";
String[] Inputs = {"A", "B", "C", "D"};
//Remove the Spaces
Console.WriteLine ("\" + input) before the string. TrimStart () + "\" ");
//Remove the specified character before the string
Console.WriteLine ("\" + input. TrimStart (', ', ') + "" ");
//Remove the Spaces
Console.WriteLine ("\" + input) after the string. TrimEnd () + "\" ");
//Remove the specified character after the string
Console.WriteLine ("\" + input. TrimEnd (', ', ') + "" ");
//Remove the Spaces
Console.WriteLine ("\" + input) before and after the string. Trim ());
//Remove the specified character before and after the string
Console.WriteLine ("\" + input. Trim (', ', ') + "" ");
//Inserts the string
Console.WriteLine (input) at the specified position of the string. Insert (0, "ABCDE"));
//Stitching string array
Console.WriteLine (String.Concat (inputs));
//concatenation of the string array with the specified delimiter
Console.WriteLine (String.Join (",", inputs));
//Use the specified delimiter to stitch the string array and specify the location
Console.WriteLine (String.Join (",", inputs, 0, 2));
//Compare two strings
Console.WriteLine (String.Compare ("abc", "abc");
//Compares two strings and ignores case
Console.WriteLine (string.comparE ("ABC", "abc", true);
Although the above methods are not of any technical content, they are very helpful to us in the process of development. In software development, technology is certainly necessary, but the foundation is very important, careful is important, quality is very important.