Mega Code Archive

 
Categories / VB.Net Tutorial / Operator
 

Compact operators

Public Class Tester     Public Shared Sub Main         Dim result As New System.Text.StringBuilder         Dim testDouble As Double = Math.PI         result.Append("Double ").AppendLine(testDouble)         testDouble += Math.PI         result.Append("+= ").AppendLine(testDouble)         testDouble *= Math.PI         result.Append("*= ").AppendLine(testDouble)         testDouble -= Math.PI         result.Append("-= ").AppendLine(testDouble)         testDouble /= Math.PI         result.Append("/= ").AppendLine(testDouble)         testDouble ^= Math.PI         result.Append("^= ").AppendLine(testDouble)         result.AppendLine()         Dim testInteger As Integer = 17         result.Append("Integer ").AppendLine(testInteger)         testInteger \= 2         result.Append("\= 2 ... ").AppendLine(testInteger)         testInteger += 1         result.Append("+= 1 ... ").AppendLine(testInteger)         testInteger <<= 1         result.Append("<<= 1 ... ").AppendLine(testInteger)         testInteger >>= 3         result.Append(">>= 3 ... ").AppendLine(testInteger)         result.AppendLine()         Dim testString As String = "Abcdef"         result.Append("String ").AppendLine(testString)         testString &= "ghi"         result.Append("&= ghi ... ").AppendLine(testString)         testString += "jkl"         result.Append("+= jkl ... ").AppendLine(testString)         Console.WriteLine(result.ToString())     End Sub End Class Double 3.14159265358979 += 6.28318530717959 *= 19.7392088021787 -= 16.5976161485889 /= 5.28318530717959 ^= 186.656996003562 Integer 17 \= 2 ... 8 += 1 ... 9 = 3 ... 2 String Abcdef &= ghi ... Abcdefghi += jkl ... Abcdefghijkl