+ 1
Вопрос в С#
double a, b, y, f; a = 0.2; b = 0.001; Console.WriteLine("Enter the y"); y = Convert.ToDouble(Console.ReadLine()); f = (a * y + b) / 2; Console.WriteLine("y={0,6:F2}; f={1,1:F2}", y, f); Console.ReadLine(); К примеру есть код. Как можно что бы f = formula; а формула вводилась тогда когда и "у" в обычном виде типо "Math.Pow(y,3) + a/b. что бы взяло формулу вставило в код и без всяких Convert работало?
1 Respuesta
+ 2
Console.WriteLine is a method with a lot of overloads.
So it can take many differen parameters.
One of them is WriteLine(String, Object)
That is the one you are using.
Quotte :
https://msdn.microsoft.com/en-us/library/system.console.writeline(v=vs.110).aspx
WriteLine(String, Object)
Writes the text representation of the specified object, followed by the current line terminator, to the standard output stream using the specified format information.
It is also allowed to do
bool Abool = true;
Console.WriteLine(Abool);
int Avalue = 1;
Console.WriteLine(Avalue);
Without any conversion.
Console.WriteLine will detect the format and do the conversion for you.
I Hope, google translate did I a good job and this was your question