本文整理汇总了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;
}
示例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));
}
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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();
}
示例8: Read
public Dictionary<String, String> Read(String response, String endpoint)
{
return Read(response.GetEnumerator(), endpoint);
}
示例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());
}
}