Bugs founded
-
Dim oBitArray1 As System.Collections.BitArray oBitArray1 = New System.Collections.BitArray(4) oBitArray1(0) = False oBitArray1(1) = True oBitArray1(2) = True oBitArray1(3) = False Dim oBitArray2 As System.Collections.BitArray oBitArray2 = New System.Collections.BitArray(4) oBitArray2(0) = True oBitArray2(1) = False oBitArray2(2) = True oBitArray2(3) = False Dim oBitArrayOR As System.Collections.BitArray oBitArrayOR = oBitArray1.Or(oBitArray2) 'This changes the content of oBitArray1. Bug? (.Net 2.0) '---------------------------------------------------------------------------------------------------------------- '| Conversion from string "" to type 'Double' is not valid. Why? | '---------------------------------------------------------------------------------------------------------------- '|Bug | '|--- | '|You cannot use a '+=' to concatenate a string with an integer because it wants sum the values and | '|therefore it tries to parse the string to a double. | '|Solution: always use '&=' to concatenate with strings. | '---------------------------------------------------------------------------------------------------------------- For i As Integer = 0 To oBitArrayOR.Count - 1 TextBox1.Text += i'oBitArray1(i) + " OR " + oBitArray2(i) + " = " + oBitArrayXOR(i) + "\r\n" Next BUT Dim x As Integer Dim s As String = s x = 1 x += 3 s += x TextBox1.Text = x & " " & s <-- No exception TextBox1.Text += x <-- Exception TextBox1.Text += x & " " & s <-- No exception So, concatenating two strings with '+=' is no problem
-
Dim oBitArray1 As System.Collections.BitArray oBitArray1 = New System.Collections.BitArray(4) oBitArray1(0) = False oBitArray1(1) = True oBitArray1(2) = True oBitArray1(3) = False Dim oBitArray2 As System.Collections.BitArray oBitArray2 = New System.Collections.BitArray(4) oBitArray2(0) = True oBitArray2(1) = False oBitArray2(2) = True oBitArray2(3) = False Dim oBitArrayOR As System.Collections.BitArray oBitArrayOR = oBitArray1.Or(oBitArray2) 'This changes the content of oBitArray1. Bug? (.Net 2.0) '---------------------------------------------------------------------------------------------------------------- '| Conversion from string "" to type 'Double' is not valid. Why? | '---------------------------------------------------------------------------------------------------------------- '|Bug | '|--- | '|You cannot use a '+=' to concatenate a string with an integer because it wants sum the values and | '|therefore it tries to parse the string to a double. | '|Solution: always use '&=' to concatenate with strings. | '---------------------------------------------------------------------------------------------------------------- For i As Integer = 0 To oBitArrayOR.Count - 1 TextBox1.Text += i'oBitArray1(i) + " OR " + oBitArray2(i) + " = " + oBitArrayXOR(i) + "\r\n" Next BUT Dim x As Integer Dim s As String = s x = 1 x += 3 s += x TextBox1.Text = x & " " & s <-- No exception TextBox1.Text += x <-- Exception TextBox1.Text += x & " " & s <-- No exception So, concatenating two strings with '+=' is no problem
So, is there is question in this, or what? There are no bugs with these operators. The '&' and '+' operators are fully documented here[^] in the VB.NET Language Concepts reference. If you use the '+' operator to concatenate strings and numbers, you have to beware of the implicit conversions involved when using it, all of which are documented here[^]. If you use the '&' operator, any operands that are not already Strings are always converted to Strings before the concatenation takes place.
Dave Kreskowiak Microsoft MVP - Visual Basic
-
So, is there is question in this, or what? There are no bugs with these operators. The '&' and '+' operators are fully documented here[^] in the VB.NET Language Concepts reference. If you use the '+' operator to concatenate strings and numbers, you have to beware of the implicit conversions involved when using it, all of which are documented here[^]. If you use the '&' operator, any operands that are not already Strings are always converted to Strings before the concatenation takes place.
Dave Kreskowiak Microsoft MVP - Visual Basic
-
Don't tell me that, tell the OP!
Dave Kreskowiak Microsoft MVP - Visual Basic
-
Don't tell me that, tell the OP!
Dave Kreskowiak Microsoft MVP - Visual Basic