20090303

But Why?

More C# thoughts. Internal Internal means only other code in your assembly can use the so-declared class. Not namespace. Not file. But assembly. That means you can swap Public and Internal all you want inside your project, even between namespaces. As long as the project compiles down to one assembly file, it doesn't make a difference. Where it makes a difference is when you need to get to the Internal class via a reference. Say you're using a second project in the solution, or you're referencing an assembly you've already installed somewhere. Your Internal types will be invisible. If you have a Public type in there and you declare a method or property Internal, the compiler won't find it either. Why would you want to do this? Perhaps you want to make some utility methods, like unit testing stuff, you don't want the paying customer to use.

0 comments:

Post a Comment