how to split textbox text when symobloye | or ; shown

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hazim
    New Member
    • Dec 2010
    • 2

    how to split textbox text when symobloye | or ; shown

    i want read from text box if there ;
    make sql qury then work thorw all string's
    can any one help C# asp
  • abhinavpratap
    New Member
    • Sep 2010
    • 9

    #2
    not sure what you are asking about. But this may help you..

    1.> if you are getting a value as "abc|def|gh i"
    Now to split it
    Concept Make a string array separated by '|'
    then you have the values and use it as you like

    Example
    Code:
    string[] SplitTextBox = TextBox1.Text.Split('|');
    Now You can access it by SplitTextBox[0],SplitTextBox[1]

    or make for loop and get the values like
    Code:
    for(int i=0;i<SplitTextBox.Length;i++)
    {
       //do something here.
       //string Value = SplitTextBox[i].ToString();
    }
    Happy Coding....

    Comment

    • NitinSawant
      Contributor
      • Oct 2007
      • 271

      #3
      use following to split the string

      Code:
      source.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)

      Comment

      Working...