# Generic and nongeneric versions of the CompareTo method for Decimal value : Decimal « Data Types « VB.Net

Home
VB.Net
 1 2D 2 Application 3 Class 4 Data Structure 5 Data Types 6 Database ADO.net 7 Date Time 8 Development 9 Event 10 File Directory 11 Generics 12 GUI 13 Internationalization I18N 14 Language Basics 15 LINQ 16 Network Remote 17 Reflection 18 Security 19 Thread 20 Windows Presentation Foundation 21 Windows System 22 XML 23 XML LINQ
 VB.Net » Data Types » Decimal Screenshots
Generic and nongeneric versions of the CompareTo method for Decimal value
 ```       Imports System Class Sample    Public Shared Sub Main()       Try                 Dim a1 As [Decimal] = -5.5D,   a2 As [Decimal] = 5.5D          Show(a1, a2, a1.CompareTo(a2), a1.CompareTo(CObj(a2)))       Catch e As Exception          Console.WriteLine(e)       End Try    End Sub    Public Shared Sub Show(var1 As [Object], var2 As [Object], resultGeneric As Integer, resultNonGeneric As Integer)       Console.WriteLine(var1)       Console.WriteLine(var2)       If resultGeneric = resultNonGeneric Then          If resultGeneric < 0 Then             Console.WriteLine("less than")          ElseIf resultGeneric > 0 Then             Console.WriteLine("greater than")          Else             Console.WriteLine("equal to")          End If                 End If    End Sub End Class                      ```
Related examples in the same category
 1 Convert String to Decimal 2 Append decimal data type values to a StringBuilder object. 3 Use the Sign(Decimal) method to determine the sign of a Decimal value and display it to the console. 4 Decimal Constructor (Double) 5 Decimal Constructor 6 Initializes a new instance of Decimal to the value of the specified 64-bit signed integer. 7 Decimal Constructor (Single) 8 Create Decimal from specified 32-bit unsigned integer. 9 Create Decimal from specified 64-bit unsigned integer. 10 Adds two specified Decimal values. 11 Decimal.Ceiling Returns the smallest integral value that is greater than or equal to the specified decimal number. 12 Decimal.Compare Method Compares two specified Decimal values. 13 Decimal.CompareTo Compares this instance to a specified Object. 14 Divides two specified Decimal values. 15 Decimal.FromOACurrency Method Converts an OLE Automation Currency value to the equivalent Decimal value. 16 Decimal.GetBits Method Converts Decimal to binary representation. 17 Decimal.Round Method Rounds a Decimal value to a specified number of decimal places. 18 Decimal.ToByte Method Converts the value of the specified Decimal to the equivalent 8-bit unsigned integer. 19 Decimal.ToDouble Method Converts Decimal to double 20 Decimal.ToInt16 Method Converts Decimal to 16-bit signed integer. 21 Decimal.ToInt32 Method Converts Decimal to 32-bit signed integer. 22 Decimal.ToInt64 Method Converts Decimal to 64-bit signed integer. 23 Decimal.ToOACurrency Method Converts Decimal to OLE Automation Currency value 24 Decimal.ToString Method 25 Decimal ToString: G 26 NumberStyles.AllowDecimalPoint 27 NumberStyles.AllowDecimalPoint Or NumberStyles.AllowThousands 28 Converts a Decimal to an 8-bit unsigned integer. 29 Converts a Decimal to a double-precision floating-point number. 30 Converts a Decimal to a 16-bit signed integer. 31 Converts a Decimal to a 32-bit signed integer. 32 Converts a Decimal to a 64-bit signed integer. 33 Converts a double-precision floating-point number to a Decimal. 34 Converts a single-precision floating-point number to a Decimal. 35 Converts an 8-bit unsigned integer to a Decimal.