How to delete last character in a string in C#?

前端 未结 10 1971
一个人的身影
一个人的身影 2020-12-23 00:21

Building a string for post request in the following way,

  var itemsToAdd = sl.SelProds.ToList();
  if (sl.SelProds.Count() != 0)
  {
      foreach (var item         


        
10条回答
  •  失恋的感觉
    2020-12-23 00:51

    Personally I would go with Rob's suggestion, but if you want to remove one (or more) specific trailing character(s) you can use TrimEnd. E.g.

    paramstr = paramstr.TrimEnd('&');
    

提交回复
热议问题