Mrz 12

C# Equivalent für VB’s “Left” Funktion

Tag: .NETMichael @ 13:35
public static string Left(string strText, int intLength)
{
    try
	{
		if (intLength < 0)
			throw new ArgumentOutOfRangeException("Length", intLength, "Length must be > 0");
		else if (intLength == 0 || strText.Length == 0)
			return "";
		else if (strText.Length <= intLength)
			return strText;
		else
			return strText.Substring(0, intLength);
	}
	catch {}
}

Dein Kommentar