How to name C# source files for generic classes

前端 未结 5 978
再見小時候
再見小時候 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:18

    I have seen some libraries using

    Bag.cs
    Bag`1.cs
    Bag`2.cs
    

    as this is what the Type.Name would display.

    I want to be more descriptive with the type parameters so I lately tend to use

    Bag.cs
    Bag{T}.cs
    Bag{TKey, TValue}.cs
    

    This is a format that is also supported by the XML comments.

    /// 
    /// ...
    /// Uses the  class.
    /// 
    

提交回复
热议问题