Array Contains by index of - CSharp System

CSharp examples for System:Array Index

Description

Array Contains by index of

Demo Code


using System.Linq;
using System.Collections.Generic;
using System;// w w  w  . ja  va2 s  .c  om

public class Main{
        /* TODO */
        /* Benchmark against the LINQ method */
        /* Will this even be called? */
        public static bool
        Contains<T>(this T[] array, T value) {

            int index = Array.IndexOf(array, value);

            bool ret = index != -1;

            return ret;

        }
        public static int
        IndexOf<T>(this T[] array, T value, int startIndex, int count) {
            return Array.IndexOf(array, value, startIndex, count);

        }
        public static int
        IndexOf<T>(this T[] array, object value, int startIndex, int count) {
            return Array.IndexOf(array, value, startIndex, count);

        }
        public static int
        IndexOf<T>(this T[] array, T value, int startIndex) {
            return Array.IndexOf(array, value, startIndex);

        }
        public static int
        IndexOf<T>(this T[] array, object value, int startIndex) {
            return Array.IndexOf(array, value, startIndex);

        }
        public static int
        IndexOf<T>(this T[] array, T value) {
            return Array.IndexOf(array, value);
        }
        public static int
        IndexOf<T>(this T[] array, object value) {
            return Array.IndexOf(array, value);

        }
}

Related Tutorials