determines whether the object is equal to any of the provided values. - CSharp System

CSharp examples for System:Object

Description

determines whether the object is equal to any of the provided values.

Demo Code

// Copyright (c) 2015 ZZZ Projects. All rights reserved
using System;//from ww  w.  j ava 2  s. co m

public class Main{
        /// <summary>
    ///     A T extension method to determines whether the object is equal to any of the provided values.
    /// </summary>
    /// <param name="this">The object to be compared.</param>
    /// <param name="values">The value list to compare with the object.</param>
    /// <returns>true if the values list contains the object, else false.</returns>
    /// ###
    /// <typeparam name="T">Generic type parameter.</typeparam>
    public static bool In(this Char @this, params Char[] values)
    {
        return Array.IndexOf(values, @this) != -1;
    }
}

Related Tutorials