What is scope of a Internal member variable of a C# class?
What is scope of a Internal member variable of a C# class?
In C#, the internal
access modifier is used to restrict the visibility of a class member (such as a variable, method, or property) to the current assembly. An assembly is a compiled unit of code that can be deployed and versioned independently.
When a member variable of a C# class is declared as internal
, it has the following scope:
Accessible within the same assembly: The internal
member variable can be accessed by any class or method within the same assembly where it is defined.
Not accessible from other assemblies: The internal
member variable cannot be accessed from outside the assembly, even if the class containing it is public and accessible from other assemblies.
Can be overridden in derived classes within the same assembly: If the class containing the internal
member variable is inherited by another class within the same assembly, the derived class can override or hide the internal
member variable.
Can be accessed by friend assemblies: If the InternalsVisibleToAttribute
is used to specify a friend assembly, the internal
member variable can be accessed from the specified friend assembly.
He...
middle
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào