S
stand__sure
I recently had need to write a function that could (potentially) create
a very large array of integers. Since .NET assumes that memory is
infinite, I was wondering if there was a way to set a safe maximum
upper bound in code for use in the class constructor. Also, in c++ one
is able to assign all the memebrs of an array to a value without
listing the full array (i.e. with a simple =0); is such a thing do-able
in VB.NET?
here is the function (maximum is a private integer member,
internalArray is a private integer array)
Public Sub New(ByVal UpperLimit As Integer)
If ((UpperLimit > Integer.MaxValue) OrElse (UpperLimit < 2)) Then
Throw New IndexOutOfRangeException("Invalid value passed to
constructor " & Me.GetType().FullName())
Exit Sub
End If
maximum = UpperLimit
ReDim internalarray(maximum)
For nloop As Integer = minimum To maximum
internalarray(nloop) = nloop 'array is 0-based
Next
End Sub
a very large array of integers. Since .NET assumes that memory is
infinite, I was wondering if there was a way to set a safe maximum
upper bound in code for use in the class constructor. Also, in c++ one
is able to assign all the memebrs of an array to a value without
listing the full array (i.e. with a simple =0); is such a thing do-able
in VB.NET?
here is the function (maximum is a private integer member,
internalArray is a private integer array)
Public Sub New(ByVal UpperLimit As Integer)
If ((UpperLimit > Integer.MaxValue) OrElse (UpperLimit < 2)) Then
Throw New IndexOutOfRangeException("Invalid value passed to
constructor " & Me.GetType().FullName())
Exit Sub
End If
maximum = UpperLimit
ReDim internalarray(maximum)
For nloop As Integer = minimum To maximum
internalarray(nloop) = nloop 'array is 0-based
Next
End Sub