Text Split with Space

前端 未结 2 1674
遥遥无期
遥遥无期 2020-12-18 12:34

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 =          


        
相关标签:
2条回答
  • 2020-12-18 12:54
    string[] temp = yourString.Split(' ');
    label1.Text = temp[0];
    label2.Text = temp[1];
    label3.Text = temp[2];
    
    0 讨论(0)
  • 2020-12-18 12:56

    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];
    
    0 讨论(0)
提交回复
热议问题