作者:再见WhoWho | 来源:互联网 | 2022-11-20 19:40
这是我在C#中的代码:一旦这个程序运行它很容易终止,我看不到它的输出,有人能告诉我这段代码有什么问题吗?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static int sum(int num1, int num2, int num3)
{
int total;
total = num1 + num2 + num3;
return total;
}
static void Main(string[] args)
{
Console.Write("\n\nFunction to calculate the sum of two numbers :\n");
Console.Write("--------------------------------------------------\n");
Console.Write("Enter a number1: ");
int n1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter a number2: ");
int n2 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter a number3: ");
int n3 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\nThe sum of three numbers is : {0} \n", sum(n1, n2, n3));
}
}
}
opewix..
8
您需要一些可以阻止控制台窗口关闭的东西,就像Console.ReadKey()
在程序结束时一样.
1> opewix..:
您需要一些可以阻止控制台窗口关闭的东西,就像Console.ReadKey()
在程序结束时一样.