Where is the best place to locate enum types?

前端 未结 10 2124
自闭症患者
自闭症患者 2020-12-25 11:16

I have found that there is generally a singe type or namespace that takes in any particular enum as a parameter and as a result I have always defined those enums there. Rece

10条回答
  •  眼角桃花
    2020-12-25 11:51

    Usually I find that the enum is centered around a single class -- as a MyClassOptions type of thing.

    In that case, I place the enum in the same file as MyClass, but inside the namespace but outside the class.

    namespace mynamespace
    {
      public partial class MyClass
      {
      }
      enum MyClassOptions
      {
      }
    }
    

提交回复
热议问题