What is the difference between a class library and a namespace?

前端 未结 2 731
轻奢々
轻奢々 2021-02-06 02:21

What is the actual difference between class library and a namespace? I know both are used to group together classes, namespace etc. Can anyone tell in which scenario should I us

2条回答
  •  独厮守ぢ
    2021-02-06 03:01

    The purpose of namespaces is to avoid name collisions. Namespace should be used when your have several hundreds of classes. Other indicator - when your code is used by somebody else and your names may collide with names in the user code.

    Other important difference is that class is always a data type. You can define variables with this type. Namespace is not a type. You cannot define vars with the namespace.

提交回复
热议问题