如何在C#.net中返回多个不同类型的对象? [英] How can I return more than one object of different type in C# .net?

查看:124
本文介绍了如何在C#.net中返回多个不同类型的对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有两个对象,并且我不想创建一个包装类来包含这两个对象的数据,没有"Out"参数可以以任何方式返回多个不同类型的对象吗?

真的会很感激的!

Hi,

I have two objects and I dont want to create a wrapper class to have data of this two object, no ''Out'' parameter is there any way that I can return more than one object of different type?

Will really appreciate it!!

Thanks

推荐答案

您可以将其中一个作为out参数.
You can make one of them an out parameter.


在这种情况下,很抱歉,但是这是一个非常愚蠢的问题.您要返回两个对象.您不想创建一个结构来保存它们.您不想使用out参数.不,显然没有其他方法可以做您想要的事情.
In that case, I''m sorry, but this is a really dumb question. You want to return two objects. You don''t want to create a struct to hold them. You don''t want to use an out parameter. No, there is quite obviously no other way to do what you want.


然后使用两种不同的方法!
Use two different methods then!


这篇关于如何在C#.net中返回多个不同类型的对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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