Is Using .NET 4.0 Tuples in my C# Code a Poor Design Decision?

前端 未结 13 1888
我在风中等你
我在风中等你 2020-12-02 04:55

With the addition of the Tuple class in .net 4, I have been trying to decide if using them in my design is a bad choice or not. The way I see it, a Tuple can be a shortcut

13条回答
  •  悲哀的现实
    2020-12-02 05:28

    Tuples are great if you control both creating and using them - you can maintain context, which is essential to understanding them.

    On a public API, however, they are less effective. The consumer (not you) has to either guess or look up documentation, especially for things like Tuple.

    I would use them for private/internal members, but use result classes for public/protected members.

    This answer also has some info.

提交回复
热议问题