title: What is thread safe (C#) ? (Strings, arrays, ... ?)
body: <p>I'm quite new to C# so please bear with me. I'm a bit confused with the thread safety. When is something thread safe and when something isn't?</p>
  
  <p>Is <strong>reading</strong> (just reading from something that was initialized before) from a field always thread safe? </p>
  
  <pre><code>//EXAMPLE
  RSACryptoServiceProvider rsa = new RSACrytoServiceProvider();
  rsa.FromXmlString(xmlString);  
  //Is this thread safe if xml String is predifined 
  //and this code can be called from multiple threads?
  </code></pre>
  
  <p>Is <strong>accessing</strong> an object from an array or list always thread safe (in case you use a for loop for enumeration)?</p>
  
  <pre><code>//EXAMPLE (a is local to thread, array and list are global)
  int a = 0;
  for(int i=0; i&lt;10; i++)
  {
    a += array[i];
    a -= list.ElementAt(i);
  }
  </code></pre>
  
  <p>Is <strong>enumeration</strong> always/ever thread safe?</p>
  
  <pre><code>//EXAMPLE
  foreach(Object o in list)
  {
     //do something with o
   }
  </code></pre>
  
  <p>Can <strong>writing and reading</strong> to a particular field ever result in a corrupted read (half of the field is changed and half is still unchanged) ?</p>
  
  <p>Thank you for all your answers and time.</p>
  
  <p><strong>EDIT:</strong> I meant if all threads are only reading &amp; using (not writing or changing) object. (except for the last question where it is obvious that I meant if threads both read and write). Because I do not know if plain access or enumeration is thread safe.</p>