public class MyClass:IDisposable?

public class MyClass : IDisposable?

Q1) 我是否应该像这样制作所有 类 以便我可以使用 using (...)?

也就是说,这是个好习惯吗?

public void Dispose()
    {
        // in its simplest form
    }

Q2) 除了我使用的需要关闭的特定对象的代码外,我还应该向 Dispose() 方法添加什么吗?

NB1:我知道我必须通过以下两种方式之一处理 IDisposable 类:

1) myClass.Dispose();

2) 使用 (MyCalss myClass = new MyClass())

NB2:我有一些 类 需要 运行 整个应用程序,所以我不会让这些 IDisposable。

不,您不必使所有 classes 都实现 IDisposable 接口。仅当您的 class 使用 非托管资源 时才应执行此操作。

根据MSDN

The primary use of this interface is to release unmanaged resources. The garbage collector automatically releases the memory allocated to a managed object when that object is no longer used. However, it is not possible to predict when garbage collection will occur. Furthermore, the garbage collector has no knowledge of unmanaged resources such as window handles, or open files and streams.

我有一些 class 需要 运行 整个应用程序,所以我不会将这些 IDisposable。

在这种情况下,前提是,您不想创建这些 class 的实例,合理的解决方案是使它们 static.