vendredi 26 novembre 2021

C# - Expecting "{" in if statement but got "("

I'm writing a program for school that emails the user once a certain device detects the moisture level is above a certain value. I don't know C/C#/C+++ (I have to write it in C# since the main program is in C#), I do know python however so using the main program combined with my Python knowledge I was able to make an if statement. The issue is, when ran it gives the error expected "{" but got "(". Since this isn't an issue in Python I don't really know what I'm doing wrong. Any help? NOTE: Emails, passwords, and names have been removed for my security.

/// Adding time (In progress. Lines 2, 3, 12, 26)

// Send email if plant is too moist
if (MoistureValue > 2) {
{
    var smtpClient = new SmtpClient("smtp.gmail.com")
{
    Port = 587,
    Credentials = new NetworkCredential("testemail@email.com", "RandomPasswordRandomNumber"),
    EnableSsl = true,
   
};

smtpClient.Send("exampleemail@email.com", "My name", "Plant Moisture", "Your plant is above its reccomended moisture go check on it!.");
}
}
// Send email if plant is too dry
if (MoistureValue < 2) { 
{
    var smtpClient = new SmtpClient("smtp.gmail.com")
{
    Port = 587,
    Credentials = new NetworkCredential("testemail@email.com", "RandomPasswordRandomNumber"),
    EnableSsl = true,
    
};
    
smtpClient.Send("exampleemail@email.com", "My Name", "Plant Moisture", "Your plant is a little dry, go water it!");
}
}

Aucun commentaire:

Enregistrer un commentaire