English 中文(简体)
并非所有代码返回值
原标题:not all code return a value
  • 时间:2012-05-27 12:59:59
  •  标签:
  • path
  • return
private static long CalculateScore(byte chances, long millisec) { int score; byte num1 = chances++; byte num2 = (byte)10; byte num3 = (byte)10; switch (Program.currLevelIndex) { case (byte)7: num2 = (byte)10; break; case (byte)11: num2 = (byte)20; break; case (byte)15: num2 = (byte)40; break; }

    if ((int)chances >= 1 && (int)chances <= 3)
        num1 = (byte)40;
    else if ((int)chances >= 4 && (int)chances <= 6)
        num1 = (byte)20;
    else if ((int)chances > 7)
        num1 = (byte)10;
    if (millisec > 480000L)
        num3 = (byte)10;
    else if (millisec >= 240000L && millisec <= 480000L)
        num3 = (byte)20;
    else if (millisec < 240000L)
        num3 = (byte)40;
    try
    {
        score = Convert.ToInt32((int)num2 * (int)num1 * (int)num3);
    }
    catch
    {
        score=0;
    }

    Console.SetCursorPosition(Program.x, Program.y);
    Console.Write("Your Score was: " + score);

_____________________________________________________________________________________________________________________________________________________________________________________________

错误是 codeScore & amp; 我找不到错误。 这是一个方法来工作 ou Help 是无线的 。

最佳回答

您指定此函数返回类型 long 的值, 但函数结束时没有返回语句返回值

您需要添加

return score;

作为 score 是计算的结果

问题回答

私人静态长OblickScore 期待型号的返回值长,但你的方法没有返回任何信息。

在方法结尾处添加以下内容。

return score; 

您可能想要将返回类型更改为 int 或分数变量修改为 long

private static int CalculateScore(byte chances, long millisec)
{
  int score; 
  byte num1;

private static long CalculateScore(byte chances, long millisec)
{
  long score; 
  byte num1;




相关问题
Code snippet paths in GCC

Background: Keil C51 on a PC, currently moving to GCC (CrossPack-AVR) on an iMac. Since I write firmware for micro s I have a lot of driver source files etc. that I need to include with my programs,...

C#/.NET app doesn t recognize Environment Var Change (PATH)

In my C# app, I am programmatically installing an Oracle client if one is not present, which requires adding a dir to the PATH system environment variable. This all works fine, but it doesn t take ...

PHP absolute path to file URI

In order to refer to a local DTD when using PHP SimpleXML, I need to convert the absolute path into a file type URI. For example, convert /home/sitename/www/xml/example.dtd to file:///home/sitename/...

Check if files with absolute and relative path exists

Is there a way to check whether files (with either an absolute or relative path) exists? Im using PHP. I found a couple of method but either they only accept absolute or relative but not both. Thanks.

How to get file path of the file with the running-vba code

I want to get the folder path from the file who is running the vba-code. For example: the vba-code is in the file C:myfolderfile.accdb and I want the vba-code to return C:myfolder Is that ...

热门标签