When is it better to use a Tuple versus a KeyValuePair?

前端 未结 4 1245
臣服心动
臣服心动 2021-02-01 11:49

I\'ve generally used the KeyValuePair type whenever I have data that is pair-related in the sense that one is a key to the other. If the data is

4条回答
  •  遇见更好的自我
    2021-02-01 12:02

    KeyValuePair is struct and Tuple is a class.

    That is the main difference which influences how the objects are copied whether by reference or values.

    and hence Tuple when passed around just uses "4byte" in 32bit OS, whereas KeyValuePair requires more based on "K and V"

    Anyhow comparing Tuple and KeyValuePair is not a good idea(doesn't makes sense for me) since both serves different purpose.

提交回复
热议问题