当前位置: 首页>>代码示例>>C#>>正文


C# ktString.Length方法代码示例

本文整理汇总了C#中KacTalk.ktString.Length方法的典型用法代码示例。如果您正苦于以下问题:C# ktString.Length方法的具体用法?C# ktString.Length怎么用?C# ktString.Length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KacTalk.ktString的用法示例。


在下文中一共展示了ktString.Length方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseInfoString

        public static Dictionary<ktString, ktString> ParseInfoString( ktString InfoStr )
        {
            int p = 0, p2 = 0;
            ktString property;
            ktString prop_name, prop_value;

            Dictionary<ktString, ktString> InfoMap = new Dictionary<ktString, ktString>();

            while (!InfoStr.IsEmpty())
            {
                p = InfoStr.IndexOf(';');
                if (p < 0)
                {
                    property = InfoStr;
                    p = InfoStr.Length() - 1;
                }
                else
                {
                    property = InfoStr.SubString(0, p).Trim();
                }
                p2 = property.IndexOf('=');
                prop_name = property.SubString(0, p2).AsUpper();
                prop_value = property.SubString(p2 + 1);

                InfoMap.Add(prop_name, prop_value);

                InfoStr.Remove(0, p + 1);
                InfoStr = InfoStr.Trim();
            }

            return InfoMap;
        }
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:32,代码来源:ktTalker.cs

示例2: Matches

        // Match and compare...
        // Find, but with a mask (using ? and *)
        public bool Matches(ktString Mask)
        {
            /* ** <note>
               For now we just cross our fingers and hopes that this function (/method?)
               actually works. We haven't runned this code yet.
                (BTW this goes with most of the whole class...)</note>
            ***/
            bool Match = false;
            bool GoOn = true;

            int Pos;
            ktTripple Joker = 0; // 1 == * and 2 == ?

            ktString MatchTmp;
            ktString Str = new ktString(GetValue());

            // Don't stop until we say so
            while (GoOn)
            {
                Joker = 0;

                // If there's no more "Joker"
                if ((Pos = ktRegEx.Find(Mask.GetValue(), "\\*|\\?")) < 0)
                {
                    // If (the rest of) the mask matches the string
                    if (Mask == Str)
                    {
                        // Stop looping
                        GoOn = false;
                        // And "OK it"
                        Match = true;
                    }
                    else
                    {
                        // Stop looping
                        GoOn = false;
                        // Didn' match...
                        Match = false;
                    }
                }
                else
                {
                    // Find a "Joker" and get everything infront of it
                    MatchTmp = Mask.SubStr(0, Pos);
                    // Remove what we got from the mask
                    Mask.Remove(0, MatchTmp.Length());

                    // Chech the "Joker"
                    //  If the first char is * in the "new mask"
                    //   then indicate that
                    if (Mask.First() == '*')
                        Joker = 1;
                    //  Or if it's ?...
                    else
                        Joker = 2;

                    // Remove the "Joker"
                    Mask.RemoveFirst();

                    // If this part of the mask doesn't match... (simply not a match)
                    if ((!MatchTmp.IsEmpty()) && (MatchTmp != Str.SubStr(0, MatchTmp.Length())))
                    {
                        // Stop looping
                        GoOn = false;
                        Match = false;
                    }
                    else
                    {
                        // As we now that this part of the mask matches the string
                        //  Remove that part from the string
                        Str.Remove(0, MatchTmp.Length());

                        // If the "Joker" is *
                        if (Joker == 1)
                        {
                            // Get the position of the next "Joker"
                            Pos = ktRegEx.Find(Mask.GetValue(), "\\*|\\?");

                            // If we didn't find a new "Joker"
                            if (Pos < 0)
                            {
                                // get the length of the rest of the mask ("find the end")
                                Pos = Mask.Length();
                                // If Pos is 0
                                if (Pos == 0)
                                    // No more mask...
                                    Pos = -1;
                            }

                            // If Pos is less than 0
                            //  This (should) means that the * was the last thing in
                            //   the mask and should therefor match the rest of the string
                            if (Pos < 0)
                            {
                                // Stop looping
                                GoOn = false;
                                // It's a match...
                                Match = true;
//.........这里部分代码省略.........
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:101,代码来源:ktString.cs

示例3: Freq

        // Get the number of occurrenses of a substring in the string
        public int Freq(ktString Str)
        {
            int Cnt = 0;

            // Go thru the string
            for (int I = 0; I < Length(); I++)
            {
                // Found a occurence
                if (SubStr(I, Str.Length()) == Str)
                {
                    // Skip the occurence..
                    //   We don't want to Count all occurences of "ab" (for instance)
                    //    when we're looking for "abab"
                    I += Str.Length() - 1;
                    // Count it...
                    Cnt++;
                }
            }

            return Cnt;
        }
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:22,代码来源:ktString.cs

示例4: Find

        // Search Functions
        // Find a substring in the string
        //   either search front-to-end (default) or end-to-front
        public int Find(ktString Needle, bool FromEnd)
        {
            int Pos = -1;
            int AddI = 1, StartI = 0, StopI = Length() -1;

            // If we should go backwards...
            if (FromEnd)
            {
                // Go backwards (Count down)
                AddI = -1;
                // start at the end
                StartI = Length() - Needle.Length();
                // Stop in the beginning
                StopI = 1;
            }

            // Go thru all characters (either forward or reverse...)
            for (int I = StartI; ((AddI * I) <= StopI) && (Pos < 0); I += AddI)
            {
                // If we found an occurence
                if (SubStr(I, Needle.Length()) == Needle)
                {
                    // Save it's position
                    Pos = I;
                }
            }

            // Return the position
            return Pos;
        }
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:33,代码来源:ktString.cs

示例5: StartsWith

        // Check if the string contains the substring Str
        public bool StartsWith(ktString Str, out ktString Rest)
        {
            bool Ret = false;

            if ((Length() >= Str.Length()) &&
                 (Str == SubStr(0, Str.Length())))
            {
                Ret = true;
                Rest = SubStr(Str.Length());
            }
            else
                Rest = "";

            return Ret;
        }
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:16,代码来源:ktString.cs

示例6: Replace

        // Replace First (or all) occurrences of substring with another one.
        //   (returns number of replacements)
        public int Replace(ktString OldString, ktString NewString, bool ReplaceAll)
        {
            // Init Variables
            int Count = 0;
            string Tmp;
            int Pos, tPos = 0;

            // Get the first position
            Pos = tPos = Find(OldString);

            // Go on as long as we can find 'OldString'
            while (tPos >= 0)
            {
                // Cut out everything before the 'OldString'
                Tmp = m_Content.Substring(0, Pos);
                // Insert 'NewString' (I.e. replace)
                Tmp = Tmp + NewString.GetValue();
                // Append everything after 'OldString'
                Tmp = Tmp + m_Content.Substring(Pos + OldString.Length());

                // Save
                m_Content = Tmp;

                // Find the next position
                tPos = SubStr(Pos + NewString.Length()).Find(OldString);
                Pos = Pos + NewString.Length() + tPos;

                // Count how many replaces we made
                Count++;

                // If we only should replace the first occurence of 'OldString'
                if (!ReplaceAll)
                    // Stop (-1 indicates that we didn't find 'OldString' again)
                    Pos = -1;
            }

            // Return the Count
            return Count;
        }
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:41,代码来源:ktString.cs


注:本文中的KacTalk.ktString.Length方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。