c# 错误 CS0115: “RPG.Form1.Dispose(bool)”: 没有找到适合的方法来重写
源代码:(还有一堆没用的,没贴)
namespace Sprite_Demo
{
     public partial class Form1 : Form
     {
         private bool p_gameOver = false;
         private int p_startTime = 0;
         private int p_currentTime = 0;
         public Game game;
         public Bitmap dragonImage;
         public Sprite dragonSprite;
         public Bitmap grass;
         public int frameCount = 0;
         public int frameTimer = 0;
         public float frameRate = 0;
         public PointF velocity;
         public int direction = 2;
         private void Form1_Load(object sender, EventArgs e)
         {
             Main();
         }
         public Form1()
         {
             InitializeComponent();
         }
         private void Form1_KeyDown(object sender, KeyEventArgs e)
         {
             Game_KeyPressed(e.KeyCode);
         }
         private void Form1_FormClosed(object sender, FormClosedEventArgs e)
         {
             Shutdown();
         }
         public void Main()
         {
             Form form = (Form)this;
             game = new Game(ref form, 800, 600);
             //load and initialize game assets
             Game_Init();
             while (!p_gameOver)
             {
                 //update timer
                 p_currentTime = Environment.TickCount;
                 //let gameplay code update
                 Game_Update(p_currentTime - p_startTime);
                 //refresh at 60 FPS
                 if (p_currentTime > p_startTime + 16)
                 {
                     //update timing
                     p_startTime = p_currentTime;
                     //let gameplay code draw
                     Game_Draw();
                     //give the form some cycles
                     Application.DoEvents();
                     //let the game object update
                     game.Update();
                 }
                 frameCount += 1;
                 if (p_currentTime > frameTimer + 1000)
                 {
                     frameTimer = p_currentTime;
                     frameRate = frameCount;
                     frameCount = 0;
                 }
             }
             //free memory and shut down
             Game_End();
             Application.Exit();
         }    }
}
------解决方案--------------------
楼主,WinForm一般不会包这个错误,Dispose方法由系统释放资源是自动调用!
MSDN上面是这样说明的:
此方法由公共方法 Dispose 和 Finalize 方法调用。Dispose 调用 disposing 参数设置为 true 的受保护方法 Dispose(Boolean)。Finalize 调用 disposing 设置为 false 的 Dispose 的方法。
当 disposing 参数为 true 时,此方法释放该 Form 引用的、由任何托管对象持有的全部资源。此方法调用每个引用对象的 Dispose 方法。
给继承者的说明 Dispose 可以由其他对象多次调用。重写 Dispose(Boolean) 时,请注意不要引用在以前调用 Dispose 时已释放的对象。
你看看你的Shutdown(),Game_End()函数有没有做特殊处理。
你可以试作把一些代码屏蔽,逐步缩小范围,直至最后确定问题点!