String\'s in C# are immutable and threadsafe. But what when you have a public getter property? Like this:
public String SampleProperty{
get;
private
Setting the string is an atomic operation, i.e. you will either get the new string or the old string, you'll never get garbage.
If you're doing some work e.g.
obj.SampleProperty = "Dear " + firstName + " " + lastName;
then string concatination all happens before the call to set, therefore sampleField will always either be the new string or the old.
If however your string concatination code is self referential e.g.
obj.SampleProperty += obj.SampleProperty + "a";
and else where on another thread you have
obj.SampleProperty = "Initial String Value";
Then you need the lock.
Consider you're working with an int. If you're assigning to the int, and any value you get from the int is valid, then you don't need to lock it.
However, if the int is keeping count of the number of widgets processed by two or more threads, for the count to be accurate, you need to lock the int. It's the same situation for strings.
I've a feeling I didn't explain this very well, hope it helps.
Thanks
BW