不断引用 [英] constant references

查看:45
本文介绍了不断引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

他们有可能吗?我传递了大量的字节,因此我不想使用ByVal。


Zytan

解决方案

Zytan写道:


它们可能吗?我传递了大量的字节,因此我不想使用ByVal。
不想使用ByVal。



按值传递数组时,没有数组的副本

内容,只有数组*变量* 。


HTH。


问候,


Branco,


Branco,


Google Groups做了些什么奇怪的是,装了一个新的页面,擦掉了整个东西(网络应用程序的一个主要缺陷 - 通过

意外加载新页面,并告别所有你的工作),所以我忘了它,并且

刚问了一个基本问题。


我打算问一下数组变量是否像C ++数组一样(即比如

指针),所以即使''指针''是常量,你仍然可以改变它指向的内容(除非那也是const)。所有VB .NET

帮助文件和教程甚至都没有触及这些内容。非常

烦人。这就像他们认为程序员不应该想这些事情一样......


无论如何......这导致了这个问题:


如何将数组传递给函数/ sub,以便整个数组

是const并且无法更改?或者我应该使用C#代替

这样的功能吗?


感谢您的回复,


Zytan


" Zytan" < zy ********** @ yahoo.comschrieb:


如何将数组传入函数/ sub以便整个数组

是const,无法更改?或者我应该使用C#代替

这样的功能?



这不能用,不能用VB而不能用C#。您必须将数组或代理对象的副本传递给函数。


-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps.org/>

VB< URL:http://dotnet.mvps .org / dotnet / faqs />


Are they possible? I am passing in a large array of Bytes, thus I
don''t want to use ByVal.

Zytan

解决方案

Zytan wrote:

Are they possible? I am passing in a large array of Bytes, thus I
don''t want to use ByVal.

When you pass an array by value, there''s no copy of the array
contents, just of the array *variable*.

HTH.

Regards,

Branco,


Branco,

I had actually typed up a lengthy post asking about that, as well, and
Google Groups did something strange, and loaded a new page, erasing
the whole thing (one major flaw of web apps -- load a new page by
accident, and say goodbye to all your work), so I forgot about it, and
just asked the basic question.

I was going to ask if array variables are like C++ arrays (i.e. like
pointers), so that even if the ''pointer'' is const, you can still
change what it points to (unless that is also const). All VB .NET
help files and tutorials never even touch upon these things. Very
annoying. It''s like they think the programmer shouldn''t be thinking
about these things...

Anyway... that leads to the question:

How can I pass in an array to a function/sub so that the entire array
is const and cannot be changed? Or should I be using C# instead for
such functionality?

Thanks for your reply,

Zytan


"Zytan" <zy**********@yahoo.comschrieb:

How can I pass in an array to a function/sub so that the entire array
is const and cannot be changed? Or should I be using C# instead for
such functionality?

This cannot be done, not in VB and not in C#. You''d have to pass a copy of
the array or a proxy object to the function.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


这篇关于不断引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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