本文整理汇总了C#中Comparison.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# Comparison.Invoke方法的具体用法?C# Comparison.Invoke怎么用?C# Comparison.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comparison
的用法示例。
在下文中一共展示了Comparison.Invoke方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IndexesOfCompared
/// <summary>
/// retrieves a sentence between signatureA and signatureB and returns the last letter of signatureB.
/// </summary>
public static List<int> IndexesOfCompared(this string str, string signatureA, string signatureB, Comparison comparer, bool BreakOnFirstYield = false , int startIndex = 0, int endIndex = -1) {
if (endIndex == -1)
endIndex = str.Length - 1;
int a = startIndex, b = endIndex;
var items = new List<int>();
while (true) {
var res = IndexBetween(str, signatureA, signatureB, a, b);
if (res[0] == -1 || res[1] >= endIndex)
break;
a = res[1];
if (res[1] == -1) {
break;
}
var s = str.Substring(res[0], res[1] - res[0]);
if (comparer.Invoke(s)) {
items.Add(res[1] + signatureB.Length - 1);
if (BreakOnFirstYield)
break;
}
}
return items;
}
示例2: StringsBetween
public static IEnumerable<string> StringsBetween(this string str, string signatureA, string signatureB, Comparison comparer, bool BreakOnFirstYield = false , int startIndex = 0, int endIndex = -1) {
if (endIndex == -1)
endIndex = str.Length - 1;
int a = startIndex, b = endIndex;
while (true) {
var res = IndexBetween(str, signatureA, signatureB, a, b);
if (res[0] == -1 || res[1] >= endIndex)
break;
a = res[1];
if (res[1] == -1) {
yield break;
}
var s = str.Substring(res[0], res[1] - res[0]);
if (comparer.Invoke(s)) {
yield return s;
if (BreakOnFirstYield)
break;
}
}
}