Get String from Left Or Empty - CSharp System

CSharp examples for System:String SubString

Description

Get String from Left Or Empty

Demo Code


using System.Text;
using System.IO;/* w  w w . j  a va 2  s. c o  m*/
using System.Globalization;
using System.Collections.Generic;
using System;

public class Main{
        public static string LeftOrEmpty(this string value, int maxLength)
        {
            if (value == null) return string.Empty;
            if (value.Length > maxLength)
            {
                value = value.Substring(0, maxLength);
            }
            return value;
        }
}

Related Tutorials