Processing a list to build an ip in a string format The point of this code is to build an ip from a list of type ushort.

var ip = new StringBuilder();
List&lt;ushort&gt; ipList = new List&lt;ushort&gt;(4) {192, 168, 1, 1};

ipList.ToList().ForEach(x =&gt; ip.Append(x + "."));

return ip.Remove(ip.Length - 1, 1).ToString();


The code works and outputs an ip as expected, but the formatting I give it leaves to be desired, having to delete the last element of the string does not look like a reliable solution or at least, I don't feel like it is.

The code above would output, before returning, the following string:

"192.168.1.1."

And after removing the last character it will look like this:  

"192.168.1.1"
There is a string.Join() method which would exactly do what you want like so  

string ip = string.Join(".", ipList);


btw,  you don't need to call ToList() on a List&lt;T&gt;.