C
C#3y ago
zxa4fd

How does `internal` work in this code? [Answered]

public class BaseClass
{
// Only accessible within the same assembly.
internal static int x = 0;
}
public class BaseClass
{
// Only accessible within the same assembly.
internal static int x = 0;
}
7 Replies
zxa4fd
zxa4fdOP3y ago
If I'm correct x is only accessible within the same .cs file
ero
ero3y ago
No, the assembly is the binary file your project compiles to. An exe or a dll.
becquerel
becquerel3y ago
Also worth noting that you can use the InternalsVisibleTo attribute in an assembly to bypass this (useful for testing projects)
ero
ero3y ago
I don't know if this has actually been implemented, but there was a planned file keyword which would do what you said
zxa4fd
zxa4fdOP3y ago
Can there be different assemblies in a project?
ero
ero3y ago
no, a project compiles to an assembly but there can be multiple projects in a solution
Accord
Accord3y ago
✅ This post has been marked as answered!

Did you find this page helpful?