Reputation: 47377
If I have a string/integer that looks like 123
, how can I convert that to look like 12.3
?
Basically what I need is something faster (if possible) than this
Math.Round(Double.Parse(input / 1000), 1).ToString
Upvotes: 0
Views: 491
Reputation: 137128
If it's an integer do:
double value = (double)integer / 10.0;
string output = value.ToString();
If it's a string then you need to convert it to an integer first:
int integer = Int32.Parse(input);
If you're not sure that the string is an integer:
bool isInt = Int32.TryParse(input, out integer);
Upvotes: 1