IDisposable metaphor in Java?

后端 未结 6 1207
滥情空心
滥情空心 2021-02-19 13:44

As a java developer getting into .NET I\'d like to understand the IDisposable interface. Could somebody please try to explain this and how it differs from what happens in Java?

6条回答
  •  借酒劲吻你
    2021-02-19 14:15

    There is no equivalent.

    It is used when you use unmanaged resources ( in Java all the resources area managed ).

    In .net memory allocated by the managed resources is collected automatically by the GC ( as in Java ) .

    You have additionally the opportunity to use unmanaged resources, where you will be responsible for the memory allocation and its release.

    You call this method when you don't need the resources anymore.

提交回复
热议问题