C# 算术运算符在编译时不会注册
刚刚开始学习c,我在运行控制台应用程序时遇到了一些问题。出于某种原因,当我运行控制台应用程序时,它运行sayHello方法,但不会运行算术方法 任何帮助都将不胜感激C# 算术运算符在编译时不会注册,c#,c#-4.0,C#,C# 4.0,刚刚开始学习c,我在运行控制台应用程序时遇到了一些问题。出于某种原因,当我运行控制台应用程序时,它运行sayHello方法,但不会运行算术方法 任何帮助都将不胜感激 using System; class Mainclass { public static void sayHello(string username, string servername) { Console.WriteLine("Could you please enter your name : ");
using System;
class Mainclass {
public static void sayHello(string username, string servername)
{
Console.WriteLine("Could you please enter your name : ");
username = Console.ReadLine();
Console.WriteLine("Hello " + username + "," + " my name is " + servername + ".");
Console.ReadLine();
}
public static float Arithmetic (float value)
{
return value * value;
}
static void Main()
{
Console.WriteLine("Hello, Welcome to the football scout app.");
sayHello((Console.ReadLine()), "Mr. Scout");
Arithmetic(200);
}
它当然会运行该方法,但您还没有实现任何输出
static void Main()
{
Console.WriteLine("Hello, Welcome to the football scout app.");
sayHello((Console.ReadLine()), "Mr. Scout");
Console.WriteLine("200 squared equals " + Arithmetic(200).ToString());
}
它当然会运行该方法,但您还没有实现任何输出
static void Main()
{
Console.WriteLine("Hello, Welcome to the football scout app.");
sayHello((Console.ReadLine()), "Mr. Scout");
Console.WriteLine("200 squared equals " + Arithmetic(200).ToString());
}
它运行的很好,你只是没有做任何事情。试试Console.writelinearith200;要在控制台中打印返回值,您如何知道它没有执行该方法?您没有从它生成任何输出,或者在您调用它之后。尝试在算术方法中放置一个断点并运行调试器。感谢大家的回复!它运行的很好,你只是没有做任何事情。试试Console.writelinearith200;要在控制台中打印返回值,您如何知道它没有执行该方法?您没有从它生成任何输出,或者在您调用它之后。尝试在算术方法中放置一个断点并运行调试器。感谢大家的回复!