csharp TrimToLength extension method

public static string TrimToLength(this string original, int length)
{
	if (original.Length > length)
	{
		original = original.Substring(0, length);
	}
	return original;
}
Use for trimming a string to a specified length, if it's longer than the length.

Updated: Thursday 19th May 2011, 16:31am

There are 0 comments

Leave a comment of your own

Comments are currently closed.