Câu hỏi phỏng vấn C#
Câu hỏi

What is scope of a Internal member variable of a C# class?

Câu trả lời

Scope of an Internal Member Variable in 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:

  1. 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.

  2. 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.

  3. 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.

  4. 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

middle

Gợi ý câu hỏi phỏng vấn

senior

What is scope of a Protected Internal member variable of a C# class?

expert

What is the use of static constructors?

senior

What is the difference between is and as operators in C#?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào