I am trying to create a small application that takes an input from the user (should be the month), and takes the first character and adds one, takes the second and adds two, and takes the third, and adds three.
I have got it working without using an extra method and just repeating myself, but wanted to try and implement one.
I am receiving the error "Program.MonthInteger(int, int)': not all code paths return a value" with my method, however, I am not sure why. It is showing a red error line under the declaration of the method.
My code is below, could someone give me a hand, and let me know where I am going wrong, please?
Thank you.
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);
}
}
}