{}

H

Herfried K. Wagner [MVP]

* "Hei said:
what's mean of {} in vb.net?

They are used to specify the contents of an array:

\\\
Dim aint() As Integer = {1, 2, 4, 8, 16}
///

In Whidbey's generics they will get an additional semantic.
 
H

Hei

Hi All

in the book of example :

Public MustInherit Class Broker

Private const m_MAXRESERVATION As Integer =10
Protected m_reservations() as Reservation

Public Sub New()
m_reservations = New Reservation(m_MAXRESERVATION ) {}

End Sub

......


another question, i know the difference of ByRef and ByVal, in the case use byref or byval don't affect the result which one is prefer? (less memory use, better performance ....)

thx
 
J

Jay B. Harlow [MVP - Outlook]

Hei,
another question, i know the difference of ByRef and ByVal,
in the case use byref or byval don't affect the result which
one is prefer? (less memory use, better performance ....)
Are you sure you know the difference? ;-)

ByVal & ByRef Parameters are independent of Reference & Value Types. All
parameters by default are passed ByVal, you should only pass a parameter
ByRef when you have to, which is when you need to modify the callers
variable.

Less memory use & better performance should not be a factor in choosing
ByVal & ByRef. The only time to consider ByRef for less memory & performance
is when passing large structures (structures as in defined with the
Structure keyword), however structures should never be large!

Structure Usage Guidelines.
http://msdn.microsoft.com/library/d...genref/html/cpconvaluetypeusageguidelines.asp

A Reference Type is an object that exists on the heap. If I have a variable
that is a reference type and assign the variable to another variable. Both
variables will be pointing to the same object on the heap.

Dim x As Person
x = New Person()
Dim y As Person
y = x

Both x & y are the exact same Person object on the heap.

A Value Type does not live on the Heap. If I have a value type variable and
I assign it to another variable, a copy of the value is made.

Dim x As Integer
x = 100
Dim y As Integer
y = x

Although both x & y have the value 100, they are physically different values
as a copy was made.

Now when you pass a variable to a ByVal parameter a copy of the variable is
made. So for a Reference Type a copy of the reference is made, which means
there is still only one object on the heap & two references to that object.
For a Value Type a copy of the value is made.

When you pass a variable to a ByRef parameter a reference to that variable
is made. So for a Reference Type you have a reference to a reference to the
object, for a Value Type you have a reference to the value.

Remember ByVal & ByRef are how parameters are passed. Reference & Value
Types are how quantities are stored.

Hope this helps
Jay



Hi All

in the book of example :

Public MustInherit Class Broker

Private const m_MAXRESERVATION As Integer =10
Protected m_reservations() as Reservation

Public Sub New()
m_reservations = New Reservation(m_MAXRESERVATION ) {}

End Sub

......


another question, i know the difference of ByRef and ByVal, in the case use
byref or byval don't affect the result which one is prefer? (less memory
use, better performance ....)

thx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top