Ejemplo n.º 1
0
        public static int?FindFirstIndex(this TextRow row, Func <string, bool> predicate)
        {
            for (var i = 0; i < row.Count; i++)
            {
                if (predicate(row[i]))
                {
                    return(i);
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
        // Method to find index of fields matching a condition

        public static IEnumerable <int> FindIndex(this TextRow row, Func <string, bool> predicate) =>
        row.Find((s, i) => predicate(s) is bool matched && matched
Ejemplo n.º 3
0
        // Methods that get the index of first match; otherwise return null

        public static int?FindFirstIndex(this TextRow row, string sought) =>
        row.FindFirstIndex(sought, StringComparison.Ordinal);
Ejemplo n.º 4
0
 public static int?FindFirstIndex(this TextRow row,
                                  string sought, StringComparison comparison) =>
 row.FindFirstIndex(s => string.Equals(s, sought, comparison));
Ejemplo n.º 5
0
 public static int GetFirstIndex(this TextRow row, Func <string, bool> predicate) =>
 row.FindFirstIndex(predicate) is int i ? i : throw new InvalidOperationException("Sequence contains no elements.");