c# - Why do i get different decimal points? -


i created structure contains several fields.
in structure have property calls method creates string out of number logging purposes.
when use property in structure different decimal points vs when directly call actual method creates log-string!
suppose have 9990m, if use structure 9990.0000 , when call method directly prints 9990.00

this method :

private static string createlog(     long userid, decimal amount,     long transactionid, decimal totalcash) {       values = string.format("{0}{1}{2}{3}",                             amount,                             userid,                             transactionid,                             totalcash);     return values; } 

and structure looks this:

public struct accountstruct         {             public long user_id;             public decimal amount;             public long transaction_id;             public decimal current_cash;             string valuestobeloged             {                                 {                    return createlog(this);                 }             }          } 

and createlog looks (calls former method)

private static string createlog(accountstruct accinfo)         {             return createlog(  accinfo.user_id,                                accinfo.amount,                                accinfo.transaction_id,                                accinfo.current_cash);         } 

why ? whats problem here?

probably sort of internal normalization going on. if care such matters, need specify how many decimal places want in tostring or string.format method.

look decimal.tostring(string) options. use "nx" x number of decimal places.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -