First, I know the role of the Split function is to Split a string into a String Array Based on the specified delimiter.
This Split is defined in ASP as dim Split (byval source as string, byval str as string) as string ()
Source is the source string, str is the Separator
I used VB.net to describe the type of the returned value and the type of the parameter.
You can see how to use it at a glance.
In C #, we use
String [] Split (string source, char [] char)
Here Char is an array of Char []. We can set new char [] {','} in this way to define only one delimiter, you can also use new char [] {',', '. ',' # '} to define multiple delimiters. This is a simple usage in C.
In ASP, multiple delimiters can be used to separate strings. How can this problem be solved?
The Split in Asp can only be a string parameter as a delimiter. After reading some documents, I did not find the method for defining multiple delimiters in ASP.
It seems that we have only handled it by ourselves. Finally, we can find a method: first, convert all the characters in the source string that we think will be treated as delimiters into a specific character, such as ",". Then we use this specific delimiter for segmentation. The example is as follows:
Lcontent = Replace (lcontent ,".",",")
Lcontent = Replace (lcontent ,"",",")
Lcontent = Replace (lcontent ,". ",",")
Lcontent = Replace (lcontent ,",",",")
Lcontent = Replace (lcontent ,"\",",")
Lcontent = Replace (lcontent ,"/",",")
Lcontent = Replace (lcontent ,"#",",")
Lcontent = Replace (lcontent ,"*",",")
Lcontent = Replace (lcontent ,"&",",")
Lcontent = Replace (lcontent ,":",",")
Lcontent = Replace (lcontent ,";",",")
Rec = Split (lcontent ,",")
In this way, the Split method in Asp uses multiple delimiters.
Learning without thinking about it is not in progress, so next I thought of the working method of Split in C.
How can we achieve good efficiency? If it uses char [0] to split the string, then use char [1] to separate it, and then use char [2], char [3]... in this way, after multiple splits, an array is formed to obtain the final result. It seems that this is not very efficient, and I personally think it will not be used to deal with it.
So I personally think that the Split in C # can also be Split by the char [] of the Split based on the method in ASP above? First, convert the same characters in source and Char [] into a specific delimiter, maybe not ',' or a Char that is basically impossible in our string, which is more secure. And then use this specific delimiter to separate. The efficiency should be much higher.
In C #, is it implemented in this way or a more efficient way? I hope someone can give me some advice.