更好的命名元组班比"项目1","项目2" [英] Better naming in Tuple classes than "Item1", "Item2"

查看:163
本文介绍了更好的命名元组班比"项目1","项目2"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有使用一个元组类,但在其提供的项目的名称的方法

Is there a way to use a Tuple class, but supply the names of the items in it?

例如:

public Tuple<int, int, int int> GetOrderRelatedIds()

这将返回OrderGroupId,OrderTypeId,OrderSubTypeId和OrderRequirementId的标识。

That returns the ids for OrderGroupId, OrderTypeId, OrderSubTypeId and OrderRequirementId.

这将是很好,让我的方法的用户知道哪个是哪个。 (当你调用该方法,结果result.Item1,result.Item2,result.Item3,result.Item4,目前还不清楚哪个是哪个。)

It would be nice to let the users of my method know which is which. (When you call the method, the results are result.Item1, result.Item2, result.Item3, result.Item4. It is not clear which one is which.)

(我知道我可以只创建一个类来容纳所有这些ID,但这些ID已经有了自己的班级,他们生活在,使这一个方法的返回值的一类,似乎傻了。)

(I know I could just create a class to hold all these Ids, but it these Ids already have their own classes they live in and making a class for this one method's return value seems silly.)

推荐答案

没有,没有办法做到这短短的定义你自己的类型。

No, there is not a way to do this short of defining your own type.

这篇关于更好的命名元组班比&QUOT;项目1&QUOT;,&QUOT;项目2&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆