C# 程序。Monthinger(int,int)和#x27;:并非所有代码路径都返回值

C# 程序。Monthinger(int,int)和#x27;:并非所有代码路径都返回值,c#,C#,我正在尝试创建一个小应用程序,它接受用户的输入(应该是月份),接受第一个字符并添加一个,接受第二个字符并添加两个,接受第三个字符并添加三个 我没有使用额外的方法,只是重复我自己,但我想尝试并实现一个 我收到了错误“Program.monthinger(int,int)”:不是所有的代码路径都返回一个值,但是,我不知道为什么。它在方法声明下显示了一条红色的错误行 我的代码在下面,有人能帮我一下,告诉我哪里出了问题吗 多谢各位 using System; using System.Collectio

我正在尝试创建一个小应用程序,它接受用户的输入(应该是月份),接受第一个字符并添加一个,接受第二个字符并添加两个,接受第三个字符并添加三个

我没有使用额外的方法,只是重复我自己,但我想尝试并实现一个

我收到了错误“Program.monthinger(int,int)”:不是所有的代码路径都返回一个值,但是,我不知道为什么。它在方法声明下显示了一条红色的错误行

我的代码在下面,有人能帮我一下,告诉我哪里出了问题吗

多谢各位

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PasswordCalculator
{
    class Program
    {
        static void Main(string[] args)
        {
            char monthOne = MonthInteger(0, 1);
            char monthTwo = MonthInteger(1, 2);
            char monthThree = MonthInteger(2, 3);

            Console.WriteLine("Your Password is {0}{1}{2}", monthOne, monthTwo, 
monthThree);
        }

        static char MonthInteger(int stringChar, int addHowLetter)
        {
            int monthLetterInt;
            char monthLetter;
            string month;

            Console.WriteLine("What month would you like the password for?");
            month = Console.ReadLine();

            monthLetterInt = month[stringChar] + addHowLetter;
            monthLetter = Convert.ToChar(monthLetterInt);
        }
    }
}

您缺少返回声明。您需要添加
returnmonthletter
作为月份整数方法的最后一行

MonthInteger方法不包含任何返回语句

查看
静态char MonthInteger(int,int)
的签名,并计算该方法有多少返回语句。错误消息不是不言自明的吗?你可以在搜索引擎的帮助下立即找到答案
monthinger
methode不包括任何
return
??啊!对谢谢。@MBH999请接受这一正确答案。抱歉,此平台为新手。现在完成:)