How to delete last char

后端 未结 5 1212
醉酒成梦
醉酒成梦 2021-01-12 15:24

How to delete last character of String with substring or anything ?

For example;

var
  query : String;
begin
  query:= \'test=1&line         


        
5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-12 16:03

    I think I would write this as:

    NewValue := OldValue.Substring(0, OldValue.Length - 1);
    

    I think the functional interface, that is a function returning a new value, is usually to be preferred over a procedure with side-effects. I find the assignment operator is a clear indicator that a new value is being assigned to the variable. Using a functional approach makes the syntax much cleaner when you want the new value to be stored in a different variable from the original value.

提交回复
热议问题