編譯器錯誤 CS0245
更新:2007 年 11 月
錯誤訊息
不能直接呼叫解構函式和 object.Finalize。請考慮呼叫 IDisposable.Dispose (如果有)。
如需詳細資訊,請參閱記憶體回收的程式設計要點和解構函式 (C# 程式設計手冊)。
下列範例會產生 CS0245:
// CS0245.cs
using System;
using System.Collections;
class MyClass // : IDisposable
{
/*
public void Dispose()
{
// cleanup code goes here
}
*/
void m()
{
this.Finalize(); // CS0245
// this.Dispose();
}
public static void Main()
{
}
}