ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core Namespace / CoreObjectsBase Class / Dispose Method / Dispose() Method
Example Version

Dispose() Method
Releases this object's unmanaged resources.
Syntax
public void Dispose()
Example
Checking for the existence of a Table
// Must be called within QueuedTask.Run9)
public bool TableExists(Geodatabase geodatabase, string tableName)
{
    try
    {
        TableDefinition tableDefinition = geodatabase.GetDefinition<TableDefinition>(tableName);
        tableDefinition.Dispose();
        return true;
    }
    catch
    {
        // GetDefinition throws an exception if the definition doesn't exist
        return false;
    }
}
Checking for the existence of a Feature Class
// Must be called within QueuedTask.Run()
public bool FeatureClassExists(Geodatabase geodatabase, string featureClassName)
{
    try
    {
        FeatureClassDefinition featureClassDefinition = geodatabase.GetDefinition<FeatureClassDefinition>(featureClassName);
        featureClassDefinition.Dispose();
        return true;
    }
    catch
    {
        // GetDefinition throws an exception if the definition doesn't exist
        return false;
    }
}
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also