本文整理汇总了C#中StringList.Sort方法的典型用法代码示例。如果您正苦于以下问题:C# StringList.Sort方法的具体用法?C# StringList.Sort怎么用?C# StringList.Sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringList
的用法示例。
在下文中一共展示了StringList.Sort方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCurrentExpectedSymbols
private StringList GetCurrentExpectedSymbols()
{
BnfTermList inputElements = new BnfTermList();
StringSet inputKeys = new StringSet();
inputKeys.AddRange(_currentState.Actions.Keys);
//First check all NonTerminals
foreach (NonTerminal nt in Data.NonTerminals) {
if (!inputKeys.Contains(nt.Key)) continue;
//nt is one of our available inputs; check if it has an alias. If not, don't add it to element list;
// and we have already all its "Firsts" keys in the list.
// If yes, add nt to element list and remove
// all its "fists" symbols from the list. These removed symbols will be represented by single nt alias.
if (string.IsNullOrEmpty(nt.DisplayName))
inputKeys.Remove(nt.Key);
else {
inputElements.Add(nt);
foreach(string first in nt.Firsts)
inputKeys.Remove(first);
}
}
//Now terminals
foreach (Terminal term in Data.Terminals) {
if (inputKeys.Contains(term.Key))
inputElements.Add(term);
}
StringList result = new StringList();
foreach(BnfTerm term in inputElements)
result.Add(string.IsNullOrEmpty(term.DisplayName)? term.Name : term.DisplayName);
result.Sort();
return result;
}