Issue
When I run this code, I get output "System.Double, 3"
namespace NewApp
{
class Program
{
static void Main(string[] args)
{
double a = 1.0;
double b = 2.7;
a = Math.Round(b);
Console.WriteLine(a.GetType() + ", " + a);
}
}
}
Why I see "3", if a
is double variable and I supposed to see "3.0"?
Solution
It is still double. You are facing with 3 instead of 3.0 because of the way Console.write works. Use this as example
Console.WriteLine(DoubleConverter.ToExactString(a))
Answered By - redParrot Answer Checked By - Willingham (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.