Sunday, May 02, 2010

C# – Useful generic delegates

Useful generic delegates, especially when you are working with lambda expressions.

Action<T> Delegate:

public delegate void Action<in T>(T obj)

Predicate<T> Delegate:

public delegate bool Predicate<in T>(T obj)

Func<T, TResult> Delegate:

public delegate TResult Func<in T, out TResult>(T arg)

Comparison<T> Delegate:

public delegate int Comparison<in T>(T x,T y)

Converter<TInput, TOutput> Delegate:

public delegate TOutput Converter<in TInput, out TOutput>(TInput input)

EventHandler<TEventArgs> Delegate:

public delegate void EventHandler<TEventArgs>(Object sender,TEventArgs e) where TEventArgs : EventArgs

No comments:

Post a Comment

Remember, if you want me to respond to your comment, then you need to use a Google/OpenID account to leave the comment.