Search code examples
c#visual-studiostructure

Structure private field accessibility


I noticed that intellisense let me "see" private field of other structure "instances". I does not understand why i can bypass getter, i think this is dangerous (i'm using VS2019).

enter image description here


Solution

  • Private fields can be accessed from code in the same class or struct, regardless of instance. This is not something new and the way the private access modifier is supposed to work and always have worked in C#.