Class.Class vs Namespace.Class for top level general use class libraries?

后端 未结 7 1754
难免孤独
难免孤独 2020-12-11 07:52

Which one is more acceptable (best-practice)?:

namespace NP
   public static class IO
   public static class Xml
   ...
   // extension methods

using NP;

I         


        
7条回答
  •  攒了一身酷
    2020-12-11 08:09

    I prefer #1 because it does not require me to call through 1 class to get to another. I think it makes things a bit confusing because in general objects are meant to have member classes, methods, and such that deal directly with the objects made by instantiating the class. That means you are not really following the principles of OOP. Microsoft also says #1 is best practice.

提交回复
热议问题