I want to split this String.
text1:text2
My code:
string[] split = line.Split(':');
Console.WriteLine(split[0])
Output:
text1
How can I get "text2" ?
You are close:
The results are 0 based, so the first string starts at 0 which is why split[0]
returns text1
.
So to get the second element text2
just use split[1]
.
您需要访问数组的第二个元素: split[1]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.