Detailed introduction to the String. Split method in asp.net

Source: Internet
Author: User

In asp.net c #, String. Split has six overload methods. The following is an example. If you need it, you can refer to it.

Below we use some examples to illustrate how to use (the following string words = "1, 2.3, 4 ";):

Split (Char ())? Invalid statement execution ?? Column ,???? The column contains ???? Why ??? By the specified Unicode character? The child string separated by the column elements.

The Code is as follows: Copy code
1. public string [] Split (params char [] separator)
String [] split = words. Split (new Char [] {','}); // return value: {"1", "2.3", "", "4 "}
String [] split = words. split (new Char [] {',', '. '}); // return: {"1", "2", "3", "", "4 "}


Split (Char (), Int32 )? Invalid statement execution ?? Column ,???? The column contains ???? Why ??? By the specified Unicode character? The child string separated by the column elements. ?? Do you have to pay for it? Why? Are you confused? /P>

The Code is as follows: Copy code
2. public string [] Split (char [] separator, int count)
String [] split = words. split (new Char [] {',', '. '}, 2); // return: {"1", "2.3, 4 "}
String [] split = words. split (new Char [] {',', '. '}, 6); // return: {"1", "2", "3", "", "4 "}

 
Split (Char (), StringSplitOptions )? Invalid statement execution ?? Column ,???? Column inclusion ??? Which of the specified Unicode characters? The child string separated by the column elements. ?? Payment overdue? Why? Column element.

The Code is as follows: Copy code
3. public string [] Split (char [] separator, StringSplitOptions options)
String [] split = words. split (new Char [] {',', '. '}, StringSplitOptions. removeEmptyEntries); // return value: {"1", "2", "3", "4"} empty element not retained
String [] split = words. split (new Char [] {',', '. '}, StringSplitOptions. none); // return: {"1", "2", "3", "", "4"} retain null Elements

 
Split (String (), StringSplitOptions )? Invalid statement execution ?? Column ,???? Column inclusion ??? Which of the following is the specified string? The child string separated by the column elements. ?? Payment overdue? Why? Column element.

The Code is as follows: Copy code
4. public string [] Split (string [] separator, StringSplitOptions options)
String [] split = words. split (new string [] {",", ". "}, StringSplitOptions. removeEmptyEntries); // return value: {"1", "2", "3", "4"} empty element not retained
String [] split = words. split (new string [] {",", ". "}, StringSplitOptions. none); // return: {"1", "2", "3", "", "4"} retain null Elements

 
Split (Char (), Int32, StringSplitOptions )? Invalid statement execution ?? Column ,???? Column inclusion ??? Which of the specified Unicode characters? The child string separated by the column elements. ?? Pay-as-you-go? Why? Why? ? About to owe? How old is it? Column element.

The Code is as follows: Copy code
5. public string [] Split (char [] separator, int count, StringSplitOptions options)
String [] split = words. split (new Char [] {',', '. '}, 2, StringSplitOptions. removeEmptyEntries); // return value: {"1", "2.3, 4"} empty elements are not retained.
String [] split = words. split (new Char [] {',', '. '}, 6, StringSplitOptions. none); // return: {"1", "2", "3", "", "4"} retain null Elements


Split (String (), Int32, StringSplitOptions )? Invalid statement execution ?? Column ,???? Column inclusion ??? Which of the following is the specified string? The child string separated by the column elements. ?? Pay-as-you-go? Why? Why? ? About to owe? How old is it? Column element.

The Code is as follows: Copy code

6. public string [] Split (string [] separator, int count, StringSplitOptions options)
String [] split = words. split (new string [] {",", ". "}, 2, StringSplitOptions. removeEmptyEntries); // return value: {"1", "2.3, 4"} empty elements are not retained.
String [] split = words. split (new string [] {",", ". "}, 6, StringSplitOptions. none); // return: {"1", "2", "3", "", "4"} retain null Elements


Note that the public string [] Split (string [] separator) function is not overloaded)

Okay.

 

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.