I have code in VB.net in below:
me.Index = Format(Convert.ToDouble(g.Trim()), "##.##")
result : 120.00
how do i same thing in C#. I don’t use format function in C#. I just want result will not place more then two value after point. i mean if i send value 120.120000 then result will be 12.12
It’s not clear what you mean by “I don’t use format function in C#” but of course you could use
string.Format. However, usingdouble.ToStringwould probably be simpler:(I’ve changed the leading
##to0to ensure that there’s always a leading digit, so you don’t get “.5” for example. Obviously if you really want the leading digits to be optional, change it to"#.##". I don’t see a benefit in using##as a prefix though.)However:
.?doubleat all. Are you sure you shouldn’t be usingdecimal?