Aurora.ScriptEngine.AuroraDotNetEngine.APIs.LSL_Api.llGetSubString C# (CSharp) Метод

llGetSubString() публичный Метод

Return a portion of the designated string bounded by inclusive indices (start and end). As usual, the negative indices, and the tolerance for out-of-bound values, makes this more complicated than it might otherwise seem.
public llGetSubString ( string src, int start, int end ) : Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.LSLString
src string
start int
end int
Результат Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.LSLString
        public LSL_String llGetSubString(string src, int start, int end)
        {

            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return new LSL_String();


            // Normalize indices (if negative).
            // After normlaization they may still be
            // negative, but that is now relative to
            // the start, rather than the end, of the
            // sequence.

            if (start < 0)
            {
                start = src.Length + start;
            }
            if (end < 0)
            {
                end = src.Length + end;
            }

            // Conventional substring
            if (start <= end)
            {
                // Implies both bounds are out-of-range.
                if (end < 0 || start >= src.Length)
                {
                    return String.Empty;
                }
                // If end is positive, then it directly
                // corresponds to the lengt of the substring
                // needed (plus one of course). BUT, it
                // must be within bounds.
                if (end >= src.Length)
                {
                    end = src.Length - 1;
                }

                if (start < 0)
                {
                    return src.Substring(0, end + 1);
                }
                // Both indices are positive
                return src.Substring(start, (end + 1) - start);
            }

            // Inverted substring (end < start)
            // Implies both indices are below the
            // lower bound. In the inverted case, that
            // means the entire string will be returned
            // unchanged.
            if (start < 0)
            {
                return src;
            }
            // If both indices are greater than the upper
            // bound the result may seem initially counter
            // intuitive.
            if (end >= src.Length)
            {
                return src;
            }

            if (end < 0)
            {
                return start < src.Length ? src.Substring(start) : String.Empty;
            }
            if (start < src.Length)
            {
                return src.Substring(0, end + 1) + src.Substring(start);
            }
            return src.Substring(0, end + 1);
        }
LSL_Api