2

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.)

1 Answer 1

7

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).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.