First, Visual Studio is just an IDE, he helps develop, he not executed, he doesn’t have to understand anything.
Second, the code performs what it was ordered to do, the computer "understands" what the programmer ordered it to do. Who has to understand what is doing is the programmer.
There are several ways to solve this. The question does not make very clear what you need to do so I will answer what I think you want.
It is necessary to consider the culture to be used in his printing.
Also it is better to use one TryParse()
since it is not certain that a value will be entered that can be converted.
I took advantage and gave a modernized in the code.
using static System.Console;
using static System.Math;
using System.Globalization;
namespace Uri_CSharp {
public class URI {
public static void Main(string[] args) {
if (double.TryParse(ReadLine(), out var raio)) {
double area = Pow(raio, 2) * 3.14159;
WriteLine(area.ToString("F4", new CultureInfo("pt-BR")));
}
}
}
}
Behold working in the ideone. And in the .NET Fiddle. Also put on the Github for future reference.
It is possible to define the standard culture for a thread, thus the Runtime consider it in place of what is configured on the computer:
Thread.CurrentThread.CurrentCulture = new CultureInfo("pt-BR");
My question was because if I compile the same code on the site http://repl.it passes exactly as I want, already in the visual studio installed on my PC is different, I imagined that there is an option in the properties of the program
– Ícaro Dantas
It exists on the computer. If you don’t tell us what the culture is, the code will run the computer culture. You have to choose to use a computer culture or a specific one. The default is to let the computer "decide".
– Maniero
I would have to change the language of windows?
– Ícaro Dantas
No, just the regional setting.
– Maniero
Can you tell me where that is?
– Ícaro Dantas
Aliaz, would have a way to decide inside the code?
– Ícaro Dantas
That’s what I said.
– Maniero
But in its form, I define whenever I will convert, would have some way to already leave defined?
– Ícaro Dantas
Leave defined where?
– Maniero
At the beginning of the code, for example, already leave the culture the way I defined forever that printing already leave the way the culture leaves
– Ícaro Dantas
http://answall.com/questions/33564/trocando-a-culture-do-sistema I saw this post, however, I could not declare this thread, it is here as if it did not exist
– Ícaro Dantas
I put in the reply.
– Maniero
No no, it just missed there, the solution I found was: Thread.CurrentThread.Currentculture = new Cultureinfo("en-US"); It is neither Currentuiculture nor en-BR
– Ícaro Dantas
What you will put, depends on what you want, the question does not make clear what you want.
– Maniero