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






Generic and nongeneric versions of the CompareTo method for Single value

   
 
Imports System

Class Sample
   Public Shared Sub Main()
      Try
      
         Dim a1 As [Single] = 6.6F, a2 As [Single] = 6.6F
         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.Append Single data type values to a StringBuilder object.
2.Use the Sign(Single) method to determine the sign of a Single value and display it to the console.
3.Single value parse: NumberStyles.AllowParentheses
4.Single.Epsilon Field represents the smallest positive Single value that is greater than zero
5.Single.Equals returns a value indicating whether this instance is equal to a specified object.
6.Single.Parse Method converts string to single-precision floating-point number
7.Single.Parse converts string in a style to its single-precision floating-point number
8.Single.Parse Method converts string in a style and culture-specific format to single-precision floating-point number
9.Single.ToString converts value to string using the specified culture-specific format information.
10.Single.ToString converts single value to string representation using the specified format.
11.Single.ToString converts this instance to string using the specified format and culture-specific format information.
12.Single value format: C
13.Single value format: E04
14.Single value format: F
15.Single value format: N
16.Single value format: P
17.Convert value read from console to Single value
18.Single.TryParse converts string in a style and culture-specific format to single-precision floating-point number
19.Single.TryParse Method converts string to single-precision floating-point number
20.Display negative value using the invariant culture
21.Display negative value using the en-GB culture.
22.Display negative value using the de-DE culture.
23.Display positive value using the invariant culture.
24.Display positive value using the en-GB culture.
25.Display positive value using the de-DE culture.