How to make the C # namespace work like Java packages so that they are automatically renamed when they are moved?

I come from Java and see that the Java package is very convenient. When you move a class to another package, it automatically changes the package. (of course, an IDE like Eclipse or Netbean)

But C # uses a namespace and does not have its own namespace, which is automatically renamed, as in Java. For example, I have a file in which a namespace com.app, and I put it in com.app, but at a later time I move this file to a folder com.lib, and its namespace is all the same com.app. Thus, I find it difficult to handle because I move it manually.

Please give me help on how to fix my problem. (that the file namespace is indicated in the folder that it contains, and when I go to another, I will automatically change). Can we do it?

+3
source share
2 answers

I will fix the problem using an IDE plugin called Resharper . (Among many, many useful features) it stands out when the namespace is incorrect (based on the folder hierarchy and the root namespace of the assembly) and can fix it for you.

, Java, , , , . , , . :

/myProject
  /extensions
     /MyExtensionMethodClass.cs

, myProject ( myProject )

+6

, # , # , , Java. .Net , .

+2

All Articles