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


C# String.GetEnumerator方法代码示例

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


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

示例1: ArrColumn

 public int ArrColumn(String Text)
 {
     CharEnumerator ce = Text.GetEnumerator();
     ce.MoveNext();
     int index = 0, columns = 0;
     while (index != Text.Length)
     {
         if (ce.Current.CompareTo(']')==0)
             break;
         index++;
         if(ce.Current.CompareTo(',')==0)
         columns++;
         ce.MoveNext();
     }
     return columns+1;
 }
开发者ID:jbezawad,项目名称:Spina_Interp_Csharp,代码行数:16,代码来源:InterpreterVisitor.cs

示例2: SendDifference

        public static void SendDifference(String contextBefore, String contextAfter)
        {
            if (contextBefore == contextAfter)
            {
                return;
            }

            int lengthBefore = contextBefore.Length;
            int lengthAfter = contextAfter.Length;

            if (contextBefore.Length > contextAfter.Length)
            {
                SendBackspace(contextBefore.Length - contextAfter.Length);
                lengthBefore = lengthAfter;
            }

            CharEnumerator bit, ait;
            int match = 0;
            for (
                bit = contextBefore.GetEnumerator(), ait = contextAfter.GetEnumerator();
                bit.MoveNext() && ait.MoveNext();
                match++)
            {
                if (bit.Current != ait.Current)
                {
                    break;
                }
            }

            if (match < lengthBefore)
            {
                SendBackspace(lengthBefore - match);
            }

            if (match < contextAfter.Length)
            {
                SendKeyStrokes(contextAfter.Substring(match));
            }
        }
开发者ID:khonsoe,项目名称:keymagic,代码行数:39,代码来源:SendInput.cs

示例3: ArrRow

 public int ArrRow(String Text)
 {
     CharEnumerator ce = Text.GetEnumerator();
     ce.MoveNext();
     int index=0,rows=0;
     while (index != Text.Length)
     {
         if(ce.Current.CompareTo('[')==0)
             rows++;
           index++;
           ce.MoveNext();
     }
     return rows;
 }
开发者ID:jbezawad,项目名称:Spina_Interp_Csharp,代码行数:14,代码来源:InterpreterVisitor.cs

示例4: VisitLoopElement

    public override void VisitLoopElement(LoopElement element)
    {
        resultMessage += "parsing loop element"+"\n";
        loop = element.getText();
        int inc=0;
        int mode = 0;
        CharEnumerator ce = loop.GetEnumerator();
        string remloop="0";
        ce.MoveNext();
        while( inc < loop.Length)
        {
            //Console.WriteLine("Writing loop value {0}", ce.Current);

            if (ce.Current.CompareTo('(') == 0 && mode != -1)
                mode = 1;
            if (ce.Current.CompareTo(' ') == 0)
            {
                remloop = loop.Substring(inc);
                break;

            }

            if (mode == 1 && ce.Current.CompareTo('(')!=0)
            {
               loopvar = string.Concat(loopvar, ce.Current.ToString());
            }

            ce.MoveNext();
            inc++;
        }
        inc = 0;
        mode = 0;
        Console.WriteLine(" variable met in loop element:{0}",loopvar);
        resultMessage += String.Format(" variable met in loop element:{0}", loopvar)+"\n";
        Console.WriteLine(" substring left to parse:{0}", remloop);
        resultMessage += string.Format(" substring left to parse:{0}", remloop)+"\n";
        ce = remloop.GetEnumerator();
        ce.MoveNext();
        ce.MoveNext();
        string startvar="";
        string endvar="";
        while (inc < remloop.Length)
        {
            if (ce.Current.CompareTo('.') > 0 && mode == 0)
            {
                startvar += ce.Current.ToString();
            }
            else if(ce.Current.CompareTo('.')==0)
            {
                mode = 1;
            }
            else if (ce.Current.CompareTo(')') == 0)
            {
                break;
            }
            if (mode == 1 && ce.Current.CompareTo('.')!=0)
            {
                endvar += ce.Current.ToString();
            }
            ce.MoveNext();
            inc++;
        }
        Console.WriteLine("starting var of the loop is: {0}\n ending var of the loop is:{1}", startvar,endvar);
        resultMessage += string.Format("starting var of the loop is: {0}\n ending var of the loop is:{1}", startvar, endvar)+"\n";
        startloopvar = int.Parse(startvar);
        endloopvar = int.Parse(endvar);
    }
开发者ID:jbezawad,项目名称:Spina_Interp_Csharp,代码行数:67,代码来源:InterpreterVisitor.cs

示例5: initialize

        private void initialize()
        {
            /* start initialize */

            int choice, i;
            String[] classes = new String[ 6 ] { "Warrior", "Theif", "Monk", "White Mage", "Black Mage", "Red Mage" };
            String name;
            Character[] characters = new Character[ Party.MAXPARTY ];

            for (i = 0; i < Party.MAXPARTY; i++)
            {/* start loop */

                mView.sendOutput("What class type do you want? You get 3.");
                mView.sendOutput(classes.GetEnumerator(), TypeEnum.STRING);
                choice = (int)mView.getInput(TypeEnum.INT);
                name = (string)mView.getInput(TypeEnum.STRING);

                characters[ i ] = CharacterCreationFactory(choice, name);

            }/* end loop */

            mGoodGuys = new Party(characters);
            mBattle = new BattleSystem(this, mGoodGuys);
            mDungeon = new Dungeon(this, mGoodGuys);
        }
开发者ID:TeamVlissides,项目名称:SourceRepo,代码行数:25,代码来源:Game.cs

示例6: vBreckets

        /*
         * validate number of brackets
         */
        private ValidationResponce vBreckets(String inStr)
        {
            bool error = false;
            int errorBegin = -1;
            int errorEnd = -1;
            ValidationResponce response = new ValidationResponce();
            String currErrorType = "validEr1";
            int openedSquareBrackets = 0;
            int closedSquareBrackets = 0;
            int openedRoundBrackets = 0;
            int closedRoundBrackets = 0;

            CharEnumerator ce = inStr.GetEnumerator();

            while (ce.MoveNext())
            {
                switch (ce.Current)
                {
                    case '(':
                        {
                            //   currErrorType = "validEr1";
                            openedSquareBrackets++;
                            break;
                        }
                    case ')':
                        {
                            //       currErrorType = "validEr1";
                            closedSquareBrackets++;
                            break;
                        }
                    case '[':
                        {
                            //    currErrorType = "validEr1";
                            openedRoundBrackets++;
                            break;
                        }
                    case ']':
                        {
                            //   currErrorType = "validEr1";
                            closedRoundBrackets++;
                            break;
                        }
                }

            }
            //  args = new String[] { ce.Current.ToString() };
            if (openedSquareBrackets != closedSquareBrackets)
            {
                error = true;
                errorBegin = inStr.LastIndexOf("(");
                errorEnd = inStr.LastIndexOf(")");
            }
            else if (openedRoundBrackets != closedRoundBrackets)
            {
                error = true;
                errorBegin = inStr.LastIndexOf("[");
                errorEnd = inStr.LastIndexOf("]");
            }
            response.setResponce(error, errorBegin, errorEnd, currErrorType);
            return response;
        }
开发者ID:HBArck,项目名称:CPU-Emulation_PostBinarry,代码行数:64,代码来源:Validator.cs

示例7: Keys

		/// <summary>
		/// Returns an IEnumerator containing the names of the keys of the message body.
		/// </summary>
		/// <param name="message">The message where to get the keys names from</param>
		/// <returns>An IEnumerator containing the keys of the message body</returns>
		public static System.Collections.IEnumerator Keys(System.Messaging.Message message)
		{
			System.String[] tempString = new System.String[((System.Collections.SortedList)message.Body).Keys.Count];
			((System.Collections.SortedList)message.Body).Keys.CopyTo(tempString, 0);
			return tempString.GetEnumerator();
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:11,代码来源:SupportClass.cs

示例8: Read

 public Dictionary<String, String> Read(String response, String endpoint)
 {
     return Read(response.GetEnumerator(), endpoint);
 }
开发者ID:RongieZeng,项目名称:aliyun-openapi-net-sdk,代码行数:4,代码来源:JsonReader.cs

示例9: convertWordToEnglish

        private void convertWordToEnglish(Dictionary<int, string> latinTable,
            String word, List<Char> list, bool asEntityCodeFlag)
        {
            bool addAkaar = false;
            char c = '\0';
            int halant = 0x4D;

            CharEnumerator iter = word.GetEnumerator();

            while (iter.MoveNext())
            {
                String result;
                c = iter.Current;
                if (isIndic(c))
                {
                    int hiBytes;
                    int loBytes;

                    splitBytes(c, out hiBytes, out loBytes);

                    if (latinTable.TryGetValue(c, out result))
                    {
                        // NOP
                    }
                    else if (loBytes == halant)
                    {
                        addAkaar = false;
                        continue;
                    }
                    else if (latinTable.TryGetValue(loBytes, out result))
                    {
                        // NOP
                    }
                    else
                    {
                        list.Add(c);
                        continue;
                    }

                    if (addAkaar && (!isVowel(c)))
                    {
                        list.AddRange(m_akaar.ToCharArray());
                    }
                    list.AddRange(result.ToCharArray());
                    addAkaar = isConsonant(c);

                }
                else if (isNoncharacter(c))
                {
                    continue;
                }
                else
                {
                    list.Add(c);
                    continue;
                }
            }

            if (addAkaar && (!isVowel(c)))
            {
                list.AddRange(m_akaar.ToCharArray());
            }
        }
开发者ID:nydehi,项目名称:gumpad,代码行数:63,代码来源:Transliterator.cs


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