static destructor

后端 未结 6 1684
情歌与酒
情歌与酒 2020-12-04 17:46

C# has static constructor which do some initialization (likely do some unmanaged resource initialization).

I am wondering if there is static destructor?

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-04 17:58

    Initializing and cleaning up unmanaged resources from a Static implementation is quite problematic and prone to issues.

    Why not use a singleton, and implement a Finalizer for the instance (an ideally inherit from SafeHandle)

提交回复
热议问题