2
Answers

How to handle decimal point value?

Member1

Member1

9y
315
1

I am little bit confuse here, that how to handle decimal point value as i have to receive values like 0.1 , 0.012334839493 , 0.00193999329 , 1 , 2 . when i get this values from database and i have to sent this values upto 4 digits , it is possible with values more than 4 digits but when value less than 4 digit (like 0.1 , 1 , 2 ) comes it gives error. it cannot handle that value , is there any way to handle this situation.

here the code ,

foreach (DataRow row in table.Rows)
{
string stock = row["stocksum_id"].ToString();
string product = row["prod_name"].ToString();
string packing = row["conversion_factor"].ToString();
string mfg = row["manufacturer_id"].ToString();
string batch = row["batchno"].ToString();
string expiry = row["expiry_date"].ToString().Substring(0, 10);
string mrp = row["mrp"].ToString();
string totq = row["current_stock"].ToString();
string[] mrpvalue = row["purchase_price"].ToString().Split('.');
string barcode = row["scan_code"].ToString();
string prodGrade = row["prod_grade"].ToString();
    if (totq.Contains("."))
  {
      totq = totq.Substring(0, 4);
   }
string[] sqldata = { stock, product, packing, mfg, batch, expiry, mrp, totq, mrpvalue[0], barcode,prodGrade };



 

Answers (2)