Monday, June 23, 2008

Making a class private to only your assembly

Sometimes in .NET you'll want to make a class that is only accessible/exposed within your assembly. This happened to me, and for the life of me I couldn't remember how to get the thing to work, but it's actually quite simple:


In VB.Net:
Friend Class MyClass
...
End Class




In C#:
internal class Widget
{
...
}


Now, it's important to note that this will limit your class's accessibility to the assembly, but it will still be visible/accessible between namespaces within the same assembly. I'm not sure how to make a class only accessible to the namespace. If you do, how about you tell us in the comments!

Labels: , ,

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Blog Home