public override string ToString()
{
StringBuilder builder = new StringBuilder();
builder.Append(scheme);
// note: mailto and news use ':', not "://", as their delimiter
if (UriParser.IsKnownScheme(scheme))
{
builder.Append(Uri.GetSchemeDelimiter(scheme));
}
else
{
builder.Append(host.Length > 0 ? Uri.SchemeDelimiter : ":");
}
if (username != String.Empty)
{
builder.Append(username);
if (password != String.Empty)
{
builder.Append(":" + password);
}
builder.Append('@');
}
if (host.Length > 0)
{
builder.Append(host);
if (port > 0)
{
builder.Append(":" + port);
}
}
if (path != String.Empty &&
builder [builder.Length - 1] != '/' &&
path.Length > 0 && path [0] != '/' &&
host.Length > 0)
{
builder.Append('/');
}
builder.Append(path);
builder.Append(query);
builder.Append(fragment);
return(builder.ToString());
}