简体   繁体   中英

How to trim a string?

Value of rate.TierId is ' Zone1_ResidentialSales_LoansEscrowServices'. i have two spaces in start of string.I want to remove those spaces. I used below code, but ot's not working'

rate.TierId.ToString().Trim()

please sugeest me some other way

string trimmedString = rate.TierId.ToString().Trim();

In addition to using trim() you could try using string.replace(oldValue, newValue).

When using the replace method you need to specify the value equating to itself eg

yourString = yourString.replace(" ", "");

字符串是不可变的,请使用新的字符串变量。

string trimmedRate = rate.TierId.ToString().Trim();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM