Is a readonly field in C# thread safe?

后端 未结 3 1313
小蘑菇
小蘑菇 2020-12-17 08:59

Is a readonly field in C# thread safe?

public class Foo
{
  private readonly int _someField;

  public Foo()
  {
    _someField = 0;
  }

  publ         


        
3条回答
  •  臣服心动
    2020-12-17 09:14

    Not looking at your example but in general it depends what is readonly applied to, for example if dictionary is declared readonly you can still update keyvalue pairs

提交回复
热议问题