AjScript.Language.StringObject.Slice C# (CSharp) Метод

Slice() приватный статический Метод

private static Slice ( IContext context, object @this, object arguments ) : object
context IContext
@this object
arguments object
Результат object
        private static object Slice(IContext context, object @this, object[] arguments)
        {
            string str = (string)@this;

            int from = 0;
            int to = str.Length;

            if (arguments.Length > 0)
                try
                {
                    from = Convert.ToInt32(arguments[0]);
                }
                catch
                {
                }

            if (arguments.Length > 1)
                try
                {
                    to = Convert.ToInt32(arguments[1]);
                }
                catch
                {
                }

            if (from < 0)
                from = str.Length + from;

            if (to < 0)
                to = str.Length + to;

            return str.Substring(from, to - from);
        }