-2
gmailPassword
とgmailAddress
のクラスレベルの変数を作成し、メッセージを確認したりメールを送信する前にログインしているかどうかを確認する必要があります。私はそれを解決しようとしましたが、それを理解できないようです。C#ユーザーのGmailアカウントと対話するGmailアプリケーションを作成する。 gmailPasswordとgmailAddressのクラスレベルの変数を作成する必要があります
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");
}
どのようなエラーが表示されますか? – Scovetta
cs0103現在のコンテキストにdoesnotが存在しません –
あなたは、クラスやフィールドの表示を怠ったプログラムのクラスレベルの変数について質問しています。 "私はそれを理解することはできません"という質問ではありません。あなたの実際の仕事を示し、*質問*をしてください。あなたの質問は「フィールドとは何か」ですか? –