功能声明 [英] Function Declaration
问题描述
如何定义函数的返回值是ByRef还是ByVal?
我有一个实用程序类,通过执行*非常重*来清理导入的记录*
许多不同方法的字符串操作,它在
DataTables上运行,超过100,000行,在4到30列之间。
我想让函数返回ByRef以获得更高的速度和内存
效率,但我看不出该怎么做。
-
Peace&快乐的计算,
Mike Labosh,MCSD
" Mr。 McKittrick经过非常仔细的考虑后,我得到了这个新系统SUCKS的结论。
- Barringer将军,战争游戏< br / >
我首先建议您使用StringBuilder,而不是使用字符串进行
重字符串操作。
其次,你的函数返回了什么?如果它返回一个引用类型,
那么你只得到指向引用类型的指针的副本,而不是引用类型本身的
副本。
" Mike Labosh" <毫升***** @ hotmail.com>在留言中写道
新闻:O4 ************** @ TK2MSFTNGP09.phx.gbl ...你如何定义是否函数的返回值是ByRef或
ByVal?
我有一个实用程序类,通过在许多不同的方法中执行*真正的重*字符串操作来清理导入的记录,它在DataTables上运行,超过100,000行,在4到30列之间。
我想让函数返回ByRef以获得更快的速度和记忆效率,但我看不出怎么做。
-
Peace&快乐的计算,
Mike Labosh,MCSD
先生。 McKittrick经过非常仔细的考虑,我得出结论,这个新系统SUCKS。
- General Barringer,War Games"
>我首先建议您使用StringBuilder而不是字符串来进行重字符串操作。
实际上,大多数东西都使用正则表达式。但是我确实使用StringBuilder
我可以。 StringBuilder让我在一半的时间内完成我们的一个导出批次
它曾经采取过:) :) :)
其次,你的函数返回了什么?如果它返回一个引用类型,那么你只获得指向引用类型的指针的副本,而不是引用类型本身的副本。
>
这个类中的所有方法原型都是这样的:
公共函数CleanSomething(ByRef value As String)As String
有一种方法可以返回一个结构。
我只是想确保我返回的返回值ByRef更大
速度/效率。
-
Peace&快乐的计算,
Mike Labosh,MCSD
" Mr。 McKittrick经过非常仔细的考虑后,我得到了这个新系统SUCKS的结论。
- Barringer将军,战争游戏< br / >
" Mike Labosh" <毫升***** @ hotmail.com>在消息中写道
news:uH ************* @ TK2MSFTNGP12.phx.gbl ...我首先会建议您使用StringBuilder而不是Strings
进行重字符串操作。
实际上,大多数内容都使用正则表达式。但是我尽可能使用StringBuilder
。 StringBuilder让我做了我们的一个导出批次的一半
以前的时间:) :) :)
其次,你的函数返回了什么?如果它返回一个引用类型,那么你只得到指向引用类型的指针的副本,
不是引用类型本身的副本。
>几乎所有这个类中的方法原型都是这样的:
公共函数CleanSomething(ByRef value As String)As String
有一种方法可以返回一个Structure,另外。
我只是想确保我返回返回值ByRef以获得更高的速度/效率。
-
和平&安培;快乐的计算,
Mike Labosh,MCSD
先生。麦基特里克经过非常仔细的考虑,我得出结论,这个新系统SUCKS。
- 将军巴林格,战争游戏
>
函数的返回值不能是ByRef或ByVal。这就是它b / b
的回报。现在,进入函数的参数可以是ByRef或
ByVal。
HTH,
Mythran
How do you define whether the return value of a function is ByRef or ByVal?
I have a utility class that cleans imported records by doing *really heavy*
string manipulation in lots of different methods, and it operates on
DataTables in excess of 100,000 rows of anywhere between 4 and 30 columns.
I''d like to get the functions to return ByRef for greater speed and memory
efficiency, but I can''t see how to do that.
--
Peace & happy computing,
Mike Labosh, MCSD
"Mr. McKittrick, after very careful consideration, I have
come to the conclusion that this new system SUCKS."
-- General Barringer, "War Games"
I would first suggest that you use a StringBuilder, rather than Strings for
heavy string manipulation.
Second, what is your function returning? If it returns a Reference Type,
then you are only getting a copy of the pointer to the reference type, not a
copy of the reference type itself.
"Mike Labosh" <ml*****@hotmail.com> wrote in message
news:O4**************@TK2MSFTNGP09.phx.gbl...How do you define whether the return value of a function is ByRef or
ByVal?
I have a utility class that cleans imported records by doing *really
heavy* string manipulation in lots of different methods, and it operates
on DataTables in excess of 100,000 rows of anywhere between 4 and 30
columns.
I''d like to get the functions to return ByRef for greater speed and memory
efficiency, but I can''t see how to do that.
--
Peace & happy computing,
Mike Labosh, MCSD
"Mr. McKittrick, after very careful consideration, I have
come to the conclusion that this new system SUCKS."
-- General Barringer, "War Games"
>I would first suggest that you use a StringBuilder, rather than Strings forheavy string manipulation.
Actually, most of the stuff uses Regex''s. But I do use StringBuilder where
I can. StringBuilder let me do one of our export batches in half the time
it used to take :):):)
Second, what is your function returning? If it returns a Reference Type,
then you are only getting a copy of the pointer to the reference type, not
a copy of the reference type itself.
Pretty much all the method prototypes in this class look like this:
Public Function CleanSomething(ByRef value As String) As String
There is one method that returns a Structure, also.
I just want to make sure I''m returning the return value ByRef for greater
speed / efficiency.
--
Peace & happy computing,
Mike Labosh, MCSD
"Mr. McKittrick, after very careful consideration, I have
come to the conclusion that this new system SUCKS."
-- General Barringer, "War Games"
"Mike Labosh" <ml*****@hotmail.com> wrote in message
news:uH*************@TK2MSFTNGP12.phx.gbl...I would first suggest that you use a StringBuilder, rather than Strings
for heavy string manipulation.
Actually, most of the stuff uses Regex''s. But I do use StringBuilder
where I can. StringBuilder let me do one of our export batches in half
the time it used to take :):):)Second, what is your function returning? If it returns a Reference Type,
then you are only getting a copy of the pointer to the reference type,
not a copy of the reference type itself.
Pretty much all the method prototypes in this class look like this:
Public Function CleanSomething(ByRef value As String) As String
There is one method that returns a Structure, also.
I just want to make sure I''m returning the return value ByRef for greater
speed / efficiency.
--
Peace & happy computing,
Mike Labosh, MCSD
"Mr. McKittrick, after very careful consideration, I have
come to the conclusion that this new system SUCKS."
-- General Barringer, "War Games"
A function''s return value can''t be ByRef or ByVal. It''s just what it
returns. Now, the parameters that go into the function can be ByRef or
ByVal.
HTH,
Mythran
这篇关于功能声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!