C#: Enumerate IP addresses in a range
<p>How do I itertate through a range of ip addresses provided by the user?</p>

<p>I'm flexible on the format, provided it allows all ranges to be specified. Perhaps something like the nmap-style:</p>

<p>'192.0.2.1'                 #   one IP address</p>

<p>'192.0.2.0-31'              #   one block with 32 IP addresses.</p>

<p>'192.0.2-3.1-254'           #   two blocks with 254 IP addresses.</p>

<p>'0-255.0-255.0-255.0-255'   #   the whole IPv4 address space</p>

<p>For example, if the user entered 192.0.2-3.1-254, I would like to know how to generate a list of all the valid ip addresses in this range so that I could iterate through them.</p>
