title: Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<System.Threading.Tasks.Task>' to <System.Threading.Tasks.Task<bool>>'
body: <p>None of the suggested solutions relate to my current issue.</p>
  <p>This is a continuation of my thread yesterday:</p>
  <p><a href="https://stackoverflow.com/questions/68946856/how-to-format-the-layout-of-email-notifications-in-console-application-using-c-s/68946976?noredirect=1#comment121850892_68946976">How to format the layout of email notifications in Console Application using C#</a></p>
  <p>In the above thread, I got the app to work in monitoring servers and apps running on them with some great help.</p>
  <p>However, it turns out that some of the servers do not allow pingings.</p>
  <p>To work around it, I attempted to rewrite the code to monitor URLs instead of servers.</p>
  <p>Right now, I have some errors that I am struggling to resolve.</p>
  <blockquote>
  <p>Cannot implicitly convert type '<code>System.Collections.Generic.IEnumerable&lt;System.Threading.Tasks.Task&gt;</code>' to '<code>System.Collections.Generic.IEnumerable&lt;System.Threading.Tasks.Task&lt;bool&gt;&gt;</code>'. An explicit conversion exists (are you missing a cast?)</p>
  </blockquote>
  <p>The error is on line 22 which is this line:</p>
  <pre><code>IEnumerable &lt; Task&lt;bool&gt; &gt; tasks = args.Select(async url =&gt;
  </code></pre>
  <p>Any ideas what changes I need to make to resolve this error?</p>
  <pre><code>using System;
  using System.IO;
  using System.Net;
  using System.Net.Mail;
  using System.Net.NetworkInformation;
  using System.Text;
  using System.Configuration;
  using System.Collections.Generic;
  using System.Threading.Tasks;
  using System.Net.Http;
  using System.Linq;
  
  namespace showserverstatus
  {
      class Program
      {
          static async Task&lt;int&gt; Main(string[] args)
          {
              System.Collections.Concurrent.ConcurrentDictionary&lt;string, string&gt; urlToStatus = new();
  
              //IEnumerable&lt;Task&lt;bool&gt;&gt; tasks = (IEnumerable&lt;Task&lt;bool&gt;&gt;)args.Select(async url =&gt;
              IEnumerable &lt; Task&lt;bool&gt; &gt; tasks = args.Select(async url =&gt;
              {
                  bool result = await ServerStatusByAsync(url);
                  urlToStatus.TryAdd(url, result ? &quot;UP&quot; : &quot;DOWN&quot;);
              });
  
              bool[] results = await Task.WhenAll(tasks);
  
              StringBuilder body = new(&quot;Please find the status of the servers below:&quot;);
              foreach (var kvp in urlToStatus)
              {
                  body.AppendLine();
                  body.AppendFormat(&quot;{0}: {1}&quot;, kvp.Key, kvp.Value);
              }
  
              await SendEmailAsync(&quot;Server Status&quot;, body.ToString());
              await Task.Delay(3000);
  
              // Return the number of servers which were down:
              return results.Count(result =&gt; !result);
          }
          static async Task&lt;bool&gt; ServerStatusByAsync(string url)
          {
              HttpClient http = new();
              using (HttpResponseMessage response = await http.GetAsync(url))
              {
                  Console.WriteLine(&quot;GET {0}: {1}&quot;, url, response.StatusCode);
  
                  if (response.IsSuccessStatusCode)
                  {
                      await SendEmailAsync($&quot;{url} WORKING&quot;, $&quot;GET {url} returned {response.StatusCode}&quot;);
                      return true;
                  }
  
                  await SendEmailAsync($&quot;{url} DOWN&quot;, $&quot;GET {url} returned {response.StatusCode}&quot;);
                  return false;
              }
          }
  
          static async Task SendEmailAsync(string subject, string body)
          {
              using MailMessage mm = new(ConfigurationManager.AppSettings[&quot;FromEmail&quot;], &quot;joeblow@gmail.com&quot;);
              mm.To.Add(&quot;joeblow@gmail.com&quot;);
              mm.CC.Add(&quot;janedoe@yahoo.com&quot;);
              mm.Subject = subject;
              mm.Body = body;
              mm.IsBodyHtml = false;
  
              SmtpClient smtp = new()
              {
                  Host = ConfigurationManager.AppSettings[&quot;Host&quot;],
                  Port = int.Parse(ConfigurationManager.AppSettings[&quot;Port&quot;]),
                  EnableSsl = true,
                  UseDefaultCredentials = false,
                  Credentials = new NetworkCredential(ConfigurationManager.AppSettings[&quot;Username&quot;], ConfigurationManager.AppSettings[&quot;Password&quot;]),
              };
  
              await smtp.SendMailAsync(mm);
          }
      }
  }
  </code></pre>