This article mainly describes the C # implementation of char character array and string conversion method, combined with the example form simple analysis of C # character array to string and string to the character array of the specific implementation skills, the need for friends can refer to the following
The example in this article describes how C # implements the conversion of char character arrays to strings. Share to everyone for your reference, as follows:
Convert a string to a character array
char[] Tempchar = Sourcestring.tochararray ();
Second, the character array is converted to a string
//method one
string str = string.Join ("", tempChar);
//Method Two
string str = string.Concat <char> (tempChar);
// Method three
string str = new string (tempChar);
Note: Method one uses a flattering approach, since the purpose of the join is to concatenate the members within the collection and to take the specified delimiter between each member, where the delimiter is specified as an empty string and the output effect implements the conversion of the character array to the string. The Concat method is used to concatenate the members of an enumerable interface in a set, which is used here. Method Three, using the construction method of the string class, recommended to use.
The above is the C # implementation of char character array and string to convert the method of the introduction of the content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!