IDisposableExtensionsDisposeAllT(T) Method
Calls the Dispose method
on all the elements of the specified array of IDisposable.
Namespace: DevCase.Extensions.IDisposableExtensionsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[EditorBrowsableAttribute(EditorBrowsableState.Always)]
public static void DisposeAll<T>(
this T[] array
)
where T : IDisposable
<ExtensionAttribute>
<EditorBrowsableAttribute(EditorBrowsableState.Always)>
Public Shared Sub DisposeAll(Of T As IDisposable) (
array As T()
)
Dim array As T()
array.DisposeAll()
public:
[ExtensionAttribute]
[EditorBrowsableAttribute(EditorBrowsableState::Always)]
generic<typename T>
where T : IDisposable
static void DisposeAll(
array<T>^ array
)
[<ExtensionAttribute>]
[<EditorBrowsableAttribute(EditorBrowsableState.Always)>]
static member DisposeAll :
array : 'T[] -> unit when 'T : IDisposable
No code example is currently available or this language may not be supported.
- array T
-
The source array of IDisposable.
- T
-
The type.
In Visual Basic and C#, you can call this method as an instance method on any object of type
T. 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).
This is a code example.
No code example is currently available or this language may not be supported.
Public Class Form1 : Inherits Form
Private Sub Test(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Shown
Dim myCol As MyDisposableType() = {New MyDisposableType}
myCol.DisposeAll()
Try
MsgBox(myCol(0).MyField)
Catch ex As NullReferenceException
MsgBox(ex.Message)
End Try
End Sub
End Class
Public Class MyDisposableType : Implements IDisposable
Public MyField As String
Public Sub New()
Me.MyField = "Default field initialization value"
End Sub
Private disposedValue As Boolean
Public Sub Dispose() Implements IDisposable.Dispose
Dispose(True)
End Sub
Protected Sub Dispose(disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
Me.MyField = ""
End If
End If
Me.disposedValue = True
End Sub
End Class
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.