Get String Right - CSharp System

CSharp examples for System:String Padding

Description

Get String Right

Demo Code


using System.Net;
using System.IO;// w  ww .j av 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 Right(string s, int n)
        {
            if (s == "" || s == null)
            {
                return null;
            }

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

            return s.Substring(s.Length - n);
        }
}

Related Tutorials