[C#] 在C#中實現VB.NET 的Left, Mid, Right方法

  • 13632
  • 0

在C#中實現VB.NET 的Left, Mid, Right方法

參考:http://blog.xuite.net/daco.chen/blog/15600335

 //實現VB.NET的String.Left, Mid, Right功能
        private string Left(string param, int length)
        {
            string result = param.Substring(0, length);
            return result;
        }
        private string Right(string param, int length)
        {
            string result = param.Substring(param.Length - length, length);
            return result;
        }

        private string Mid(string param, int startIndex, int length)
        {
            string result = param.Substring(startIndex, length);
            return result;
        }

        private string Mid(string param, int startIndex)
        {

            string result = param.Substring(startIndex);
            return result;
        }