locked
Trim String RRS feed

  • Question

  •  

    In my report, i  have a TextBox which retrieve the result from the database.I am using this code :

     

    =Fields!Category.Value.ToString().Trim(" ").TrimEnd(",").TrimStart(",")

     

    But i am encountering a problem,wherein,when the value contains '&' (ex. Jog & Hop)

    the result became Jog&Hop.

    What could be wrong with my trim???

    Thanks!!

    Friday, December 14, 2007 7:38 AM

All replies

  •  

    Looks like the space in-between (before and after &) is being taken out and hence you might be seeing Jog&Hop or JogJog&Hop(HTML equivalent)

     

    Wednesday, January 9, 2008 8:30 PM
  • C# Example, you may want to use Replace to get at spaces surrounding "&"

    string test = "Jog & Hop"; Console.WriteLine(test.Trim(' ').TrimEnd(',').TrimStart(',')); Console.WriteLine(test.Trim(' ').TrimEnd(',').TrimStart(',').Replace(" ",""));


    Wednesday, February 13, 2019 2:52 PM