In
Checks if object is any of provided values separated by comma
Source
public static bool In<T>(this T s, params T[] values)
{
return values.Any(x => x.Equals(s));
}
Example
public enum VehicleType
{
Car,
Bike,
Truck,
Bus
}
public bool IsCarOrBike(VehicleType vehicle)
{
return vehicle.In(VehicleType.Car, VehicleType.Bike);
}
public bool IsValidGender(string textToValidate)
{
return textToValidate.In("m", "f", "male", "female");
}