Is write array an atom in C #?

var a = new bool[]{true,false};
var b = new bool[4];
a=b;       //operation 1
a[1]=true; //operation 2

I know that there are some atmoic types defined in C # where I cannot find an array from.

  • Opration 1 is a bit of a pointer reassignment. Does it guarantee to be atmoid?
  • How about operation 2?
+5
source share
2 answers

Operation 1 is atomic. Operation 2 no. From the specification :

5.5 Atomicity of variable references

: bool, char, byte, sbyte, short, ushort, uint, int, float reference. , . , long, ulong, double decimal, , .

. a b , 1 : .. . 2 bool, , . , ( a[1]), .

+5

, , a[1]=true; , =true , (a[1]=true;) 1 , true

-1
source

Source: https://habr.com/ru/post/1680370/


All Articles