locked
Best way to remove last pipe if it is the last character in a string RRS feed

  • Question

  • User-1188570427 posted

    What is the best way to remove the last character of a string if that character is a Pipe ( | )?

    Example:

    I am doing a for each loop and putting a pipe after each item to use in a split later.

    It puts the last Pipe on and then is done with the for each.

    I need to remove that last pipe OR not put it on there at all.

    What is the best way to do this?

                    StringBuilder stb = new StringBuilder();
                    foreach (var field in currentPivot.Fields.OfType<PivotGridField>().Where(x => x.UnboundType != DevExpress.Data.UnboundColumnType.Bound))
                    {
                        stb.Append(field.ID);
                        stb.Append("|");
                    }

    Thursday, February 21, 2019 2:07 PM

Answers

All replies