If you right click on a project in Visual Studio (2010), under application tab there is a property called Default namespace. Both C# and VB.Net treat it differently.
In VB.Net, by specifying default namespace project property, it is default root namespace of your library if you don't specify any for your class which is really what it should do I think. For instance, if you had a following class in file MyClass.vb and it had no namespace defined and your default namespace in project setting was set to MyApplication, you will access this class as MyApplication.MyClass.
1: Class MyClass
2: Public Function MyMethod()
3: ' Do something
4: End Function
5: End Class
In C#, default namespace property is only used as a namespace template name when you create new files. It does not effect the root namespace of your library (dll). For instance, If default namespace was set to MyApplication with following class then your class will end up in no namespace. To access your class in other projects, you just have to type MyClass which is not the solution one would want to keep, since all classes from this library will end up in default namespace (no namespace).
1: class MyClass
2: {
3: public void MyMethod()
4: {
5: // Do something
6: }
7: }
No comments:
Post a Comment