Keyword 'friend' in C#?

  • Thread starter Thread starter Hyun-jik Bae
  • Start date Start date
H

Hyun-jik Bae

Is there anything in C# correspondent to 'friend' keyword in C++?
I searched documents and found something [assembly:blahblah] but I am not
sure if it is what I am searching for.

Please reply. Thanks in advance.

Hyun-jik Bae
 
The closest thing in C# is the "internal" access modifier. Basically,
this means that only other types in the same module can access it. For most
purposes, that means assembly (since there is usually only one module in an
assembly).

Hope this helps.
 
Hyun-jik Bae said:
Is there anything in C# correspondent to 'friend' keyword in C++?
I searched documents and found something [assembly:blahblah] but I am not
sure if it is what I am searching for.

Please reply. Thanks in advance.

Hyun-jik Bae

C# 2.0 allows you to specify "friend" assemblies. Basically, this
allows you to expose internal types to another assembly. This is done
with the assembly attribute InternalsVisibleTo. So, to let assembly 2
access assembly 1's internal types, you would add:

[assembly:InternalsVisibleTo ("assembly2")]

to assembly 1.

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top