4 ms·
(0) The problem with `Using` is that you can forget to use it. Or you can use it with the wrong object. It's no better than `free()` in C. On the other hand, yo
by catnaroek 10y ago
(0) The problem with `Using` is that you can forget to use it. Or you can use it with the wrong object. It's no better than `free()` in C. On the other hand, you when you program in VB6, you can't forget to reference-count your objects, because the language implementation does it for you.
(1) Noted.
(2) I know the difference between `ReDim` and `ReDim Preserve`. And I'm not talking about the array's contents, I'm talking about the array's object identity. In VB6, both `ReDim` and `ReDim Preserve` preserve the array's identity in spite of the size change. .NET arrays don't support resizing at all, so VB.NET hides the limitation by only allowing `ReDim` on local array variables, and implementing it internally in terms of swapping array objects.
And `List` stops being natural when you want it to be multidimensional.
- cm2187 10y ago(0) you can forget to call "Dispose" but the benefit of using "using" is that Dispose will get called whichever way you get out of the scope. Using "using" for disposable types ends up being some reflex and it would seem odd to me to see new SqlConnection without a using. (2) I am not sure I agree with that either. The following in VB6 returns 10, i.e. the second redim has created a new instance of an array: Dim V() As String, W() As String ReDim V(10) W = V ReDim V(20) MsgBox UBound(W)
- catnaroek 10y ago(0) You can't forget to call “Dispose” if you need objects to be cleaned up in a specific order. (2) Try this: Dim V() As Long, W() As Long, i As Long ReDim V(1 To 10) For i = LBound(V) To UBound(V) V(i) = i Next i W = V For i = LBound(W) To UBound(W) W(i) = 2 * i Next i Call MsgBox(V(5)) Call MsgBox(W(5))