When should you use C# indexers?

后端 未结 10 1582
终归单人心
终归单人心 2020-12-06 10:10

I\'d like to use indexers more, but I\'m not sure when to use them. All I\'ve found online are examples that use classes like MyClass and IndexerClass

10条回答
  •  抹茶落季
    2020-12-06 10:32

    IMHO, Indexers are probably best if you're trying to spruce up a packaged API - it's not worth the effort for your run of the mill business object.

    And if you're making some specialized collection, I'd categorize that as sprucing up your packaged API - even if you keep it all in one module.

提交回复
热议问题