Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 C# 中执行以下操作是否安全,或者至少是“良好做法”:
string cnt; .... cnt = cnt.Trim();
(例如,在 C 中,有时你必须小心这种赋值。)
是的,它是安全的,而且字符串通常是一个好主意,因为它们是不可变的(原始对象未更改,Trim()返回对新对象的引用)。
Trim()