Search Results

Search found 1 results on 1 pages for 'elektrostudios'.

Page 1/1 | 1 

  • Give a number to return the approximated value of an Enum?

    - by ElektroStudios
    I have this enumeration: Enum Lame_Bitrate kbps_8 = 8 kbps_16 = 16 kbps_24 = 24 kbps_32 = 32 kbps_40 = 40 kbps_48 = 48 kbps_56 = 56 kbps_64 = 64 kbps_80 = 80 kbps_96 = 96 kbps_112 = 112 kbps_128 = 128 kbps_144 = 144 kbps_160 = 160 kbps_192 = 192 kbps_224 = 224 kbps_256 = 256 kbps_320 = 320 End Enum And I would like to return the approximated value of the Enum given a number. For example, if I have the number 190 then I expect to find the more approximated value in the Enum to return the 192 (kbps_192 value of the Enum), if I have the number 196 then again I expect to return the value 192 (not return the next value 224 because is less approximated). Something like this: Private Sub Test() Dim wma_file As String = "C:\windows media audio file.wma" Dim wma_file_Bitrate As Integer = 172 Dim mp3_bitrate_approximated As Integer mp3_bitrate_approximated = Return_Approximated_Value_Of_Enum(wma_file_Bitrate) End Sub private function Return_Approximated_Value_Of_Enum(byval value as integer) as integer return... enum.find(value).approximated... end function Exist any framework method to find the more approximated number given other number in a Enum? I hope you can understand my question, thank you. PS: I prefer a solution using LINQ extensions if can be.

    Read the article

1