Pregunta

What is the difference in the compiled code between a private or a protected and a public class member? Is there any check during runtime whether one can access the member or not? I am asking these questions in context of C#.

¿Fue útil?

Solución

After compilation to IL, the information is preserved. A compiled module (DLL) can be referenced by other code and then private/public/protected do matter.

After compilation from IL to native machine code, there is no difference.

Is there any check during runtime whether one can access the member or not?

I'm not totally sure but I would think this is part of the Type-loader. Code that (w/o Reflection) accesses a private variable that it shouldn't know about has to break a rule somewhere.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top