带空格的文本分割 [英] Text Split with Space
本文介绍了带空格的文本分割的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这行 C:\ pagefile.sys 128 256
,我需要获取值示例:
I have this Line C:\pagefile.sys 128 256
and i need to get the value example:
label1.text = C:\pagefile.sys
label2.Text = 128;
label3.text = 256;
所有值都是可变的,有可能吗?
all values are variable, it is possible?
推荐答案
您无需为 Split
指定空格字符,因为如果没有传递任何字符(或者如果 null
). Split()
与说 Split(new char [0]);
相同,这是由于
You don't need to specify a whitespace character for Split
as that's the default if no characters are passed (or if null
is used). Split()
is the same as saying Split(new char[0]);
due to the params overloaded method.
string input = @"C:\pagefile.sys 128 256";
string[] splitString = input.Split();
label1.Text = splitString[0];
label2.Text = splitString[1];
label3.Text = splitString[2];
这篇关于带空格的文本分割的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文