Click here to Skip to main content
15,886,689 members
Articles / Programming Languages / C#

Making Internal Access Specifiers Available to Other Assemblies

Rate me:
Please Sign up or sign in to vote.
4.68/5 (6 votes)
4 Oct 2013CPOL2 min read 10.5K   95   9  
How to make internal access specifiers available to other assemblies
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.CompilerServices;
using Assembly3;

// Now, Assembly1 is a friend of Assembly2.
// Hence, the types and Members with internal scope in Assembly2 will be visible in Assembly1.
[assembly: InternalsVisibleTo("Assembly1")] 
namespace Assembly2
{
    public class ClassB
    {
        internal static void Method1()
        {
            Console.WriteLine("Method1() in ClassB is called.");
        }

        internal static string GetName()
        {
            return ClassC.Name; // Accessing the INTERNAL property from ClassC.
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions