locked
Remove "," from front of string?

    Question

  • I am saving data to my database, separated by "," but a comma keeps getting added to the front of the string.  I can't seem to figure out how to remove the "," from the front without removing it from the rest of the string...  I would really appreciate some help if anyone knows a way that I can do this...

    Here is my code:

    Code Block

    string parameterClause = "";
                for (int i = 0; i < ListView1.Items.Count; i++)
                {
                    if (i == 0)
                    {
                        parameterClause = ListView1.Items[0].Text;
                    }
                    else
                    {
                        parameterClause += "," + ListView1.Items[i].Text;
                    }
                }



    Thank you very much for your help.  Smile
    Saturday, January 05, 2008 2:56 AM

Answers

  • Code Block

    string s = ", item1, item2, item3, item4, item5, item6";

    s = s.TrimStart(new char[] { ',' });

     

     

    Saturday, January 05, 2008 3:28 AM

All replies

  • Code Block

    string s = ", item1, item2, item3, item4, item5, item6";

    s = s.TrimStart(new char[] { ',' });

     

     

    Saturday, January 05, 2008 3:28 AM
  • Thank you very much for your help, that took care of it perfectly.

    Thank you again.
    Saturday, January 05, 2008 6:08 AM