title: How to get a single response when going through an array using logic
body: <p>Testing interview questions:</p>
  <p>I have an <code>if</code> statement to check if all condition of an IP address are met and if it is I want it to write if the IP address is valid or not. I'm supposed to be using loops logic myself and not use other class libraries such as IPAddress.parse</p>
  <pre><code>public static void Main(string[] args)
  {
      string ipAddress = &quot;10.121.300.21&quot;;
      string[] sections = ipAddress.Split('.');
      string invalid = &quot;The IP address: {0} is invalid!&quot;;
      string valid = &quot;The IP address: {0} is valid&quot;;
  
      for (var i = 0; i &lt; sections.Length; i++)
      {
          double ipNum = int.Parse(sections[i]);
  
          if (ipNum &gt; 0 &amp;&amp; ipNum &lt; 255 &amp;&amp; sections.Length == 4)
          {
              Console.WriteLine(valid, ipAddress);
          }
          else
          {
              Console.WriteLine(invalid, ipAddress);
              Console.WriteLine(&quot;section number {0} is invalid. &quot;, sections[i]);
          }
      }
  }
  </code></pre>
  <p>Right now it returns:</p>
  <pre class="lang-none prettyprint-override"><code>The IP address: 10.121.300.21 is valid
  The IP address: 10.121.300.21 is valid
  The IP address: 10.121.300.21 is invalid!
  section number 300 is invalid. 
  The IP address: 10.121.300.21 is valid```
  </code></pre>
  <p>I would like it to return whether it's valid or not in one line instead of running through each item in the array individually</p>