Short Casting Error in C# -


i trying short variables value database , need cast gives casting error @ debugging how can solve problem ?can me?

    obj_objimagegallery.watermark =string.isnullorempty((dr["watermark"]).tostring()) ? null : (short?)(dr["watermark"]);       

try this.

short? s = string.isnullorempty((dr["watermark"]).tostring()) ? null : (short?)short.parse(dr["watermark"].tostring()); 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -