public static string decode_string(byte[] x, ref int f)
{
string s = "";
while (x[f] != ':')
{
s += (char)x[f];
f++;
}
f++;
Regex r = new Regex("^(0|[1-9][0-9]*)$", RegexOptions.Compiled);
//if (!r.IsMatch(s))
//throw new BitTorrentException("Integer value is invalid");
int l = int.Parse(s);
string temp = "";
if (l > 0)
{
StringBuilder sb = new StringBuilder(l);
int i = f;
f += l;
while (i < f)
sb.Append((char)x[i++]);
return sb.ToString();
}
return temp;
}