If

public static T If<T>(this T val, Func<T,bool> predicate, Func<T, T> func)
{
    if(predicate(val))
    {
        return func(val);
    }
    return val;
}
Example:
var lang = GetLanguage();

lang.If(l=>l.Name!="Spanish", l=> MessageBox.Show("Non-spanish language!"));

Description

Executes a function if a given predicate is true

Details

Double click on the code to select all.

 

;