C# Check if a decimal has more than 3 decimal places?

后端 未结 13 1867
一生所求
一生所求 2020-12-03 14:04

I have a situation that I cannot change: one database table (table A) accepts 6 decimal places, while a related column in a different table (table B) only has 3 decimal plac

13条回答
  •  忘掉有多难
    2020-12-03 14:31

    Public Function getDecimalCount(decWork As Decimal) As Integer
    
        Dim intDecimalCount As Int32 = 0
        Dim strDecAbs As String = decWork.ToString.Trim("0")
    
        intDecimalCount = strDecAbs.Substring(strDecAbs.IndexOf(".")).Length -1
    
        Return intDecimalCount
    
    End Function
    

提交回复
热议问题