Determine if DataColumn is numeric

前端 未结 3 803
小鲜肉
小鲜肉 2020-12-09 10:47

Is there a better way than this to check if a DataColumn in a DataTable is numeric (coming from a SQL Server database)?

  Database db = DatabaseFactory.Creat         


        
3条回答
  •  隐瞒了意图╮
    2020-12-09 11:18

    Another method without using Arrays, just by one line of code:

    return col != null && "Byte,Decimal,Double,Int16,Int32,Int64,SByte,Single,UInt16,UInt32,UInt64,".Contains(col.DataType.Name + ",");
    

    This line of code can be used either as a normal helper method or as an extension method.

提交回复
热议问题