C # Introduction to the method of converting char character array to string

Source: Internet
Author: User
Tags array to string
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)!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.