If it is passed ByVal, which I thought was the default, would this be heavy on memory if the MyClass Class contained a lot of variables? And if it is ByVal, would it be more effecient for me to pass it ByRef cause it will make a pointer and not copy the whole object?
Thank you
Ryan
Hi Ryan,
Dim MyClassObject as New MyClass()
ParseMyObject(MyClassObject)Public Sub ParseMyObject(MyClassObject as MyClass)
asfsfsad
End Sub
There is no point in passing Reference types (classes) ByRef. Any Reference type is, basically, smart pointer with type information and reference to actual class data. When you passing class ByVal, this structure being copied, but it reference the same location of actual data on heap. Bottom line: in most cases pass classes ByVal.
Is there a known list that defines "Reference" Type object?
I've read in one of the .net books that these operate differently? it didn't work for me though...
dim a as string = "123"
dim b as string = a
a = "456"
response.write(b) 'this would write 456 to the screendim x as integer = 4
dim y as integer = x
x = 6
response.write(y) 'this would write 4 to the screen?
So i'm guessing strings are always reference types and integers are not?
Help is appreciated
Thankyou
ryan
Hi Ryan,
It is bit confusing. String is reference type, but it behaves much like value type. It is immutable (new copy created on each change). Integers and other basic types are value types. SeeStrings UNDOCUMENTED for great in depth look at .NET strings.
0 comments:
Post a Comment