Home > DeveloperSection > Forums > Short Casting Error in C#
Ashish Pandey

Total Post:128

Points:898
Posted on    May-10-2013 2:08 AM

 C# C# 
Ratings:


 1 Reply(s)
 1135  View(s)
Rate this:
Hi Everyone!

I am trying to get short variables value from my database and need to cast it but it gives an casting error at debugging how can I solve this problem ?Can you help me?

 obj_OBJimagegallery.watermark =String.IsNullOrEmpty((dr["watermark"]).ToString()) ? null : (short?)(dr["watermark"]);     

Please help me!
Thanks is advance!  



AVADHESH PATEL

Total Post:604

Points:4228
Posted on    May-10-2013 9:10 AM

Hi Ashish!

You can try as following

short? s = String.IsNullOrEmpty((dr["watermark"]).ToString()) ? null : (short?)short.Parse(dr["watermark"].ToString());

I hope it is helpful for you!

Don't want to miss updates? Please click the below button!

Follow MindStick