---
title: "Return empty string in decimal function"  
description: "Return empty string in decimal function"  
author: "Anonymous User"  
published: 2014-08-25  
updated: 2014-08-25  
canonical: https://www.mindstick.com/forum/2120/return-empty-string-in-decimal-function  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Return empty string in decimal function

I create a [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) to [compare](https://www.mindstick.com/forum/2036/propertyinfo-getvalue-unable-to-compare-datetimes) the price of my item. This is my function:

```
public static decimal ComparePrice(decimal Price, decimal WebsitePrice)    {        decimal ZERO_PRICE = 0.00000M;        if(Price == ZERO_PRICE && WebsitePrice > ZERO_PRICE){            return WebsitePrice;        }else if(Price == ZERO_PRICE && WebsitePrice == ZERO_PRICE){            return "";        }else{            return Price;        }    }
```

if the both(price and websiteprice) is equal 0.00, then it will return the [empty string](https://www.mindstick.com/forum/12697/json-stringify-is-sending-empty-string),

I know it is not possible to return the string while the function is set to [decimal](https://www.mindstick.com/forum/34709/please-write-a-program-for-decimal-to-binary-conversion-in-c-sharp) type,

but i have no idea what should I do about that. [Anyone](https://www.mindstick.com/articles/23207/how-to-find-the-best-fit-job-for-anyone) can help?

Thanks.

## Replies

### Reply by Sumit Kesarwani

Hi Ashish, try this:

```
public static decimal? ComparePrice(decimal Price, decimal WebsitePrice)    {        if(Price ==decimal.Zero && WebsitePrice > decimal.Zero){            return
WebsitePrice;        }else if(Price == decimal.Zero && WebsitePrice == decimal.Zero){            return
         null;        }else{            return
      Price;        }    }
```


---

Original Source: https://www.mindstick.com/forum/2120/return-empty-string-in-decimal-function

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
