Click or drag to resize
EnumerableExCatchTSource, TException Method (IEnumerableTSource, FuncTException, IEnumerableTSource)
Creates a sequence that corresponds to the source sequence, concatenating it with the sequence resulting from calling an exception handler function in case of an error.

Namespace: System.Linq
Assembly: System.Interactive (in System.Interactive.dll) Version: 1.2.0.0
Syntax
C#
public static IEnumerable<TSource> Catch<TSource, TException>(
	this IEnumerable<TSource> source,
	Func<TException, IEnumerable<TSource>> handler
)
where TException : Exception

Parameters

source
Type: System.Collections.GenericIEnumerableTSource
Source sequence.
handler
Type: SystemFuncTException, IEnumerableTSource
Handler to invoke when an exception of the specified type occurs.

Type Parameters

TSource
Source sequence element type.
TException
Exception type to catch.

Return Value

Type: IEnumerableTSource
Source sequence, concatenated with an exception handler result sequence in case of an error.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableTSource. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
See Also