You can always decompile the string.Trim() method to find out also:
Code:
public string Trim()
{
return this.TrimHelper(2);
}
private string TrimHelper(int trimType)
{
int num = this.Length - 1;
int num2 = 0;
if (trimType != 1)
{
num2 = 0;
while (num2 < this.Length && char.IsWhiteSpace(this[num2]))
{
num2++;
}
}
if (trimType != 0)
{
num = this.Length - 1;
while (num >= num2 && char.IsWhiteSpace(this[num]))
{
num--;
}
}
return this.CreateTrimmedString(num2, num);
}
private string CreateTrimmedString(int start, int end)
{
int num = end - start + 1;
if (num == this.Length)
{
return this;
}
if (num == 0)
{
return string.Empty;
}
return this.InternalSubString(start, num, false);
}
You can see that if the length doesn't change it just returns itself.