using Function

Deprecated  in 5.0 - will not be removed until after 2026-06-13. Use using declarations instead.

A 'using' function which is a substitution for .NET's using statement. It makes sure that 'dispose' is called on the resource no matter if the func returns or throws. If func returns, the return value of this function is equal to return value of func. If func throws, this function also throws (after disposing the resource).

using<T extends IDisposable, TResult>(resources: T | T[], func: (...r: T[]) => TResult): TResult

Parameter Type Description
resources T | T[]  
func (...r: T[]) => TResult  

Returns - TResult

Defined in

Last Updated: 27 June, 2025