我正在写一个程序使用的方法,我超级失去了。我的任务是here,但我无法弄清楚如何从一种方法获取值到另一种方法。现在我再澄清一点,我需要第二种方法中的值转移到主要方法,而不是特别的为我工作。我不知道如何返回值C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Ch7Ex3a
{
public class Program
{
public void stuff()
{
}
static void Main(string[] args)
{
double length=0,depth=0,total=compute;
Console.Write("What is the length in feet? ");
length=Convert.ToDouble(Console.ReadLine());
Console.Write("What is the depth in feet? ");
depth = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("${0}", total);
Console.ReadKey();
}
static double compute(double length,double depth)
{
double total;
total = length*depth* 5;
return total;
}
}
}
谢谢你的时间我知道这不是最好的代码。
你想达到什么目的?什么不正确? –
'total = compute'永远不会编译。首先阅读关于C#编程的MSDN文章作为起点。 –
该任务需要您创建一个新班级。该类应位于Main()所在的Program类后面。程序类的所有方法必须是静态的。用户生成类的方法不需要是静态的。 – jdweng