Truncate String - CSharp System

CSharp examples for System:String Shorten

Description

Truncate String

Demo Code



public class Main{
        public static string Truncate(this string str, int length) {

			ParamIs.NotNull(() => str);/*www. j av a 2s . c om*/

			return (str.Length > length ? str.Substring(0, length) : str);

		}
}

Related Tutorials