Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Is it safe, or at least a "good practice", in C# to do things like this:
string cnt; .... cnt = cnt.Trim();
(In C, for instance, sometimes, you have to be careful with that kind of assignment.)
Yes, it's safe and it's often a good idea with strings since they are immutable (the original object is unchanged, Trim() returns a reference to a new object).
Trim()
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.