Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
[MarshalAs( UnmanagedType.Currency)]           
public decimal dePrice;


I am using above code for passing dePrice= 230.00125 but i receive dePrice = 230.0012 at Other end though TCP Socket, so how can i get actual value without changing datatype?
Posted
Updated 4-Sep-14 21:05pm
v3
Comments
George Jonsson 5-Sep-14 3:11am    
What is the data type on the receiving end?
Maybe the problem lies there.
s.tradetech 15-Sep-14 3:27am    
There is same datatype at other end
Sinisa Hajnal 5-Sep-14 3:33am    
Maybe the currency type for your cultures currency has a limit to four decimals? Try sending it without MarshalAs or Marshal as decimal and see what you get.

1 solution

It looks Currency numbers are rounded to four decimal places (see, for instance this MSDN[^] page). I suggest you using the Decimal[^] data type instead.
 
Share this answer
 
Comments
s.tradetech 15-Sep-14 3:31am    
is there any datatype other than Currency for decimal value ?
CPallini 15-Sep-14 5:15am    
There is Decimal (I have already suggested you it).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900