在类/函数之间传递大量数据 [英] Passing large amounts of data between classes/functions

查看:116
本文介绍了在类/函数之间传递大量数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在编写一个应用程序,它将在

类/函数之间传递大量数据。


在C ++中,发送指向对象的指针更有效,例如结构

而不是传递实际结构本身。


这也适用于C#?


传递大量不同数据类型数据的最佳方法是什么?


例如对象可以包含一些字符串,双精度,字节等。


问候

Macca

Hi,

I''m writing an application that will pass a large amount of data between
classes/functions.

In C++ it was more efficient to send a pointer to the object, e.g structure
rather than passing the actual structure itself.

Is this true of C# also?

What is the best way to pass a large amount of data with different data types?

e.g object could contain some strings, doubles, bytes etc.

Regards
Macca

推荐答案

Macca,


我会返回对DataSet的引用,它具有相应的

信息(如果它是结构是流动的,或者创建一个具有特定信息的类的b $ b实例,然后你可以返回一个引用(类的实例,而不是结构)是参考

类型,你传递t他参考)。


希望这会有所帮助。

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com

" MACCA" <马*** @ discussions.microsoft.com>在消息中写道

新闻:54 ********************************** @ microsof t.com ...
Macca,

I would return a reference to a DataSet, which has the appropriate
information (if it is something where the structure is fluid), or create an
instance of a class which has the specific information, which you can then
return a reference to (instances of classes, not structures are reference
types, and you pass around the reference).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Macca" <Ma***@discussions.microsoft.com> wrote in message
news:54**********************************@microsof t.com...


我正在编写一个将在
类/函数之间传递大量数据的应用程序。 />
在C ++中,发送指向对象的指针更有效,例如
结构而不是传递实际结构本身。

这是真的吗? C#也是?

使用不同数据类型传递大量数据的最佳方法是什么?

例如,对象可能包含一些字符串,双精度,字节等等

Macca
Hi,

I''m writing an application that will pass a large amount of data between
classes/functions.

In C++ it was more efficient to send a pointer to the object, e.g
structure
rather than passing the actual structure itself.

Is this true of C# also?

What is the best way to pass a large amount of data with different data
types?

e.g object could contain some strings, doubles, bytes etc.

Regards
Macca



Macca写道:
我是编写一个将在类/函数之间传递大量数据的应用程序。

在C ++中,发送指向对象的指针更有效,例如结构而不是通过实际结构本身。

C#也是如此?

使用不同数据类型传递大量数据的最佳方法是什么?

例如,对象可能包含一些字符串,双精度,字节等。
I''m writing an application that will pass a large amount of data between
classes/functions.

In C++ it was more efficient to send a pointer to the object, e.g structure
rather than passing the actual structure itself.

Is this true of C# also?

What is the best way to pass a large amount of data with different data types?

e.g object could contain some strings, doubles, bytes etc.




除非你处理大价值类型(结构),否则你不需要担心这个问题。请参阅
http://www.pobox.com/ ~sibet / csharp / parameters.html


Jon



Unless you''re dealing with large value types (structs) you don''t need
to worry about this. See
http://www.pobox.com/~skeet/csharp/parameters.html

Jon


可能值得指出实例通过引用在C#

中发送,例如


private void foo(MyObject obj)

{


}


''obj''是一个参考。此规则的例外是值类型

(结构),其中包括String类。

It might be worth pointing out instances are sent by reference in C#
e.g.

private void foo(MyObject obj)
{

}

''obj'' is a reference. The exception to this rule is value types
(structs) which includes the String class.


这篇关于在类/函数之间传递大量数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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