says that I have a string str = "45.6767676"; Now in the output I need to show as 45.67 if the string is str = "4"; then display the output as 4 is there a built-in function to do this. thanks
double value = double.Parse(str); Console.WriteLine(value.ToString("##.##"));
Look here: http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx
Just check if the string contains a decimal. If so, use the options provided in the link posted by Jouke. If it isn't, then don't do anything.
Console.WriteLine(Double.Parse("4.676767").ToString("0.##"));