Get from String Left - CSharp System

CSharp examples for System:String Padding

Description

Get from String Left

Demo Code


using System.Net;
using System.IO;//from   ww w  . j a  v a 2s .  c  om
using System.Text.RegularExpressions;
using System.Web;
using System.Text;
using System.Collections.Generic;
using System;

public class Main{

        public static string Left(string s, int n)
        {
            if (string.IsNullOrEmpty(s))
            {
                return null;
            }

            if (n <= 0 || n > s.Length) return s;

            return s.Substring(0, n);
        }
}

Related Tutorials