Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between an internal and a public class in c#? [duplicate]

Tags:

c#

.net

What does the following class declarations mean ?

internal class A { }

public class B { }

I am able to access both of them in another class in another assembly using the reference of the assembly having class A and B. What's the difference in internal and public access specifiers in terms of class?

like image 852
Aditya Shukla Avatar asked Oct 24 '25 15:10

Aditya Shukla


1 Answers

Internal is only available within the assembly it resides in.

Public is available to any assembly referencing the one it resides in.

If you can access the internal class from another assembly you either have "InternalsVisibleTo" set up, or you're not referencing the class you think you are.

like image 99
Logarr Avatar answered Oct 27 '25 05:10

Logarr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!