---
title: "Short Casting Error in C#"  
description: "Short Casting Error in C#"  
author: "Anonymous User"  
published: 2013-05-10  
updated: 2013-05-10  
canonical: https://www.mindstick.com/forum/854/short-casting-error-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Short Casting Error in C#

Hi Everyone!\
I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to get short [variables](https://www.mindstick.com/articles/715/php-variables) value from my [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) and need to cast it but it gives an casting [error](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing) at [debugging](https://www.mindstick.com/blog/393/javascript-debugging) how can I [solve this problem](https://answers.mindstick.com/qa/94681/my-google-assistant-shows-completely-different-search-results-from-what-i-ask-how-can-i-solve-this-problem) ?Can you help me?\
obj_OBJimagegallery.[watermark](https://www.mindstick.com/blog/136/using-watermark-functionality-in-textbox-by-jquery) =String.IsNullOrEmpty((dr["watermark"]).ToString()) ? null : (short?)(dr["watermark"]); \
Please help me!Thanks is [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)! \

## Replies

### Reply by AVADHESH PATEL

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!


---

Original Source: https://www.mindstick.com/forum/854/short-casting-error-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
