How to name C# source files for generic classes

前端 未结 5 985
再見小時候
再見小時候 2020-12-01 13:57

I am trying to stick to general naming conventions such as those described in Design Guidelines for Developing Class Libraries. I put every type into its own source file (an

5条回答
  •  一个人的身影
    2020-12-01 14:34

    In the CoreFX GitHub repository, Microsoft is following the back-tick convention described in Matthias Jakobsson's answer:

    enter image description here

    So basically:

    class ImmutableArray { }                      // ImmutableArray.cs
    class ImmutableArray { }                   // ImmutableArray`1.cs
    ...
    class ImmutableDictionary { }   // ImmutableDictionary`2.cs
    

    And for classes defined inside other classes, the name is composed by the outer class followed by + and by the name of the inner class (Outer+Inner.cs):

    partial class ImmutableArray               // ImmutableArray`1+Builder.cs
    {
        class Builder { }
    }
    

提交回复
热议问题