Thanattha Bussapak

Thanattha Bussapak

  • NA
  • 20
  • 18.8k

How to Trim and Split string to textbox

Jan 29 2014 10:09 AM
I am try to trim ABCD - abcd ,I want output :
fList_s.Text = ABCD
fList_d.Text = abcd
but fList_s.Text = ABCD - abcd

String strList = "ABCD - abcd"

string[] items = new string[]
{
    strList
};
foreach (string item in items)
{
    string trimmed = item.TrimStart('-', ' ');               
fList_s.Text = trimmed;  //
}

char[] charsToTrim = { '-', ' ' };
                string[] words = strList.Split();
                foreach (string dest in words)                 
fList_d.Text = dest; //

Answers (2)