C
C#2y 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
zxa4fd2y ago
If I'm correct x is only accessible within the same .cs file
ero
ero2y ago
No, the assembly is the binary file your project compiles to. An exe or a dll.
Becquerel
Becquerel2y ago
Also worth noting that you can use the InternalsVisibleTo attribute in an assembly to bypass this (useful for testing projects)
ero
ero2y 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
zxa4fd2y ago
Can there be different assemblies in a project?
ero
ero2y ago
no, a project compiles to an assembly but there can be multiple projects in a solution
Accord
Accord2y ago
✅ This post has been marked as answered!
Want results from more Discord servers?
Add your server
More Posts