Convert an array of doubles to a concatenated Hex string I'm working on a tool that converts data between two systems. System 1 presents me with arrays of latitudes and longitudes as doubles. System 2 requires an input of that array as a single Hex string.

I've been calling the following method to do the conversion, and then appending a string with the results, however I'm finding that it is extremely slow, as it's being called 12-13 million times in a typical conversion.

var string = "";
foreach(var value in list&lt;geo&gt;)
string += (DoubleToHex(value.lat) + DoubleToHex(value.lon))


public static string DoubleToHex(double input)
{
    byte[] byteArray = BitConverter.GetBytes(input);
    StringBuilder hex = new StringBuilder(byteArray.Length * 2);
    foreach (byte b in byteArray)
        hex.AppendFormat("{0:x2}", b);
    return hex.ToString().ToUpper();
}


What alternatives exist that would be quicker then using StringBuilder, (or what else am I missing)?
string is immutable type, whenever you modify a string, it actually creates a new string.

if you convert it to StringBuilder such as : 

var sb = new StringBuilder(string.Empty);

foreach (var value in list)
    sb.Append(DoubleToHex(value.lat)).Append(DoubleToHex(value.lon));


You'll gain more performance. 

However, the DoubleToHex() also can simplified further to : 

public static string DoubleToHex(double input)
{
    return BitConverter.ToString(BitConverter.GetBytes(input)).Replace("-", "");
}


this will boost the performance further.