How to Char character array element for the logo, and presented it split String of characters:?.! Zhang Jun-hong Chengdu National Day everyone have a good time of it during the holiday season, but fortunately have time to go to the bookstore to buy a book, take a look at this, this book called <
Let's take a look at tocharaRray () and split (), because it is related to this issue.
First look at the TocharaRray () method, which is copied to the characters in this instance to the Unicode character array, which belongs to the String class, which can convert the string to a character array, such as:
String str = "this is";
CHAR [] ARR;
Arr = str.tochararray (); // put "this is string" separately separates the element of the char array
If we want to output a look (assuming a listbox control) method is as follows:
Foreach (char [] cin arr)
{
ListBox1.Items.add (c.toString ());
}
The result is this:
T
Hide
I
S
I
S
Take a look at this result, you can understand that it is an element that is separated by a Char array of spaces.
Let's take a look at the split () method:
The split () method is identifying the sub-string in this instance (which separates one or more characters specified in the array) and puts these sub-strings into a string array.
It has two overload versions:
Public String []
Split
(params char []);
with
Public String []
Split
(char [], int);
We speak the first version, and the latter version is explained in MSDN.
Its parameter is a char [] array, which is the elements in char [] as the identifier of the division, and the divided results are deposited in the String [] array, let's take an example:
String stra sca = "what is this?, Oh, orange!";
String [] ARSTR;
ARSTR = stra.Split (Str.ToChararray ()); // Str is "this IS" defined earlier
At this time, the element in the arstr [] array is an element generated by 7 characters in the STR to identify the STRA character.
Let's take a look at the results.
FOREACH (String CC in Arstr)
{
ListBox1.Items.add (cc.tostring ());
}
The result is:
WA
?, o
Orange!
String [] An array ARSTR does not appear in the arr array, as it is used as a segmentation identifier.
At this point, everyone may understand the relationship between characters and arrays, if so, I will satisfy!