Напишите метод для gmailpassword и gmailaddress
Я все время получаю имя "gmailPassword", а "gmaillAddress" не существует в текущем контексте. Я знаю, что должен написать метод для этого, но понятия не имею, как это сделать
class Program { static void Main(string[] args) { int userSelection; do { userSelection = Menu(); if (userSelection == 2) { loggingOn(); } else if (userSelection == 2) { getMail(); } else if (userSelection == 4) { sendMail(); } } while (userSelection != 4); public static int Menu() { if (loggedIn()) { Console.WriteLine("__________Menu__________"); Console.WriteLine("1) Close the application"); Console.WriteLine("2) Enter your credentials"); Console.WriteLine("3) Check for messages "); Console.WriteLine("4) Send a message"); Console.WriteLine("________________________"); } else { Console.WriteLine("____________Menu____________"); Console.WriteLine("1) Close the application"); Console.WriteLine("2) Enter your Credentials"); Console.WriteLine("____________________________"); Console.WriteLine("what would like to do?"); } return Convert.ToInt32(Console.ReadLine()); } public static bool loggedIn() { if(gmailAddress == "" || gmailPassword == "") { return false; } else { return true; } } public static void loggingOn() { Console.WriteLine("Enter your gmail address: "); gmailAddress = Console.ReadLine(); Console.WriteLine("Enter your gmail password"); gmailPassword = Console.ReadLine(); } public static void getMail() { string[] messages = Gmail.getMail(gmailAddress, gmailPassword); Console.WriteLine(); Console.WriteLine("_____Messages_____"); for (int i = 0; i < messages.Length; i++) { Console.WriteLine(messages[i]); Console.WriteLine(); } Console.WriteLine("_____________"); } static void sendMail() { Console.WriteLine("To address :"); string toAddress = Console.ReadLine(); Console.WriteLine("Subject :"); string subject = Console.ReadLine(); Console.WriteLine("Message :"); string messageBody = Console.ReadLine(); Gmail.sendMail(gmailAddress, gmailPassword, toAddress, subject, messageBody); Console.WriteLine("message sent"); } } } }
Что я уже пробовал:
Пока ничего. я попытался написать то, что, как я думал, сработает, но это не сработало
Bryian Tan
компилировался ли код? или вы неправильно разместили код? Посмотри, как там некоторые недостающие бирки