Tool to refactor C# var to explicit type

前端 未结 7 644
陌清茗
陌清茗 2020-12-03 17:15

Our coding standards ask that we minimise the use of C# var (suggests limiting it\'s use to being in conjunction with Linq). However there are times when using generics wher

7条回答
  •  眼角桃花
    2020-12-03 17:36

    I'd argue that where you have complex generic types on your domain objects you should typedef them

    class DomainValueCollection : KeyValue>{}
    

    where DomainValueCollection is somehting that makes sense in your domain context

    the code then becomes

    var allItems = new DomainValueCollection();
    

    rather than

    var allItems = new KeyValue>();
    

提交回复
热议问题