Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is a readonly field in VB.NET thread safe? For example, see the code below:

Class Customer
  ReadOnly Name As String

  ReadOnly ZIP As Integer = 98112

  Sub New(ByVal Name As String)

    Me.Name = Name

  End Sub
End Class
share|improve this question
By field do you mean a variable or a property? – briddums Jun 8 '12 at 14:02
up vote 4 down vote accepted

Yes, if nobody can write it, everyone is synced on its value.

Besides, you could make this integer constant (or shared readonly)

share|improve this answer
you are helpful – Anon Jun 8 '12 at 8:25
I would strongly recommend making it constant, as this documents that A) ZIP will not change within the constructor and B) that all customers have the same ZIP. B is achievable without A by making it shared. – Brian Jun 8 '12 at 17:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.