String and string, Stringstring
StringAndStringDifference
From the perspective of location:
1.String is the String in. NET Framework, and the string in lower case is the string in C # language.
2. If you delete using System;, there is no upper-case String. System is a function name in the. NET Framework class library.
In terms of nature:
1.String is a keyword and String is a class. string cannot be the name of a class, structure, enumeration, field, variable, method, or attribute.
2.When writing code in C #, try to use a lower-case string, which is more compliant. If efficiency is pursued, you can use a String in upper case, because after compilation, lowercase strings are converted to uppercase strings, which can reduce the compilation load and improve the running efficiency.
3.String represents a string of Unicode characters. String is the alias of a string in. NET Framework. It is more intuitive to test the equality of strings.
StringDetails:
String s = string. Empty: A string variable pointing to an Empty string. The. s variable can be used, for example, s. Length.
String s = ""; an empty string pointing to "\ 0" occupies a byte storage space, because the Escape Character \ 0 indicates that the string ends. s variable can be used, such as s. Length
String s = null; a variable that does not belong to any bucket. s cannot be used.
Single Character Segmentation:
String s = "abcdeabcdeabcde ";
String [] sArray = s. Split ('C ');
Foreach (string I in sArray)
Console. WriteLine (I. ToString ());
Output the following results:
AB
Deab
Deab
De
Separate multiple characters:
String s = "abcdeabcdeabcde
String [] sArray1 = s. Split (new char [3] {'C', 'D', 'E '});
Foreach (string I in sArray1)
Console. WriteLine (I. ToString ());
You can output the following results:
AB
AB
AB
Separate multiple characters(Regular Expression):
String content = "agcsmallmacsmallgggsmallytx ";
String [] resultString = Regex. Split (content, "small", RegexOptions. IgnoreCase)
Foreach (string I in resultString)
Console. WriteLine (I. ToString ());
Output the following result: agc
Mac
Ggg
Ytx