小编blu*_*gic的帖子

错误'timer_Tick'的重载与委托'System.EventHandler <object>'匹配

我不确定我的代码有什么问题,有人可以帮助修复错误吗?错误timer.Tick()在行中.它应该是一个秒表.

namespace App3
{
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {                
            this.InitializeComponent();
        }
        private int myCount;

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            DispatcherTimer timer = new DispatcherTimer();
            timer.Tick += new EventHandler<object>(timer_Tick);
            timer.Interval = TimeSpan.FromSeconds(5);
            timer.Start();    
        }


        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            base.OnNavigatedFrom(e);
        }

        private void timer_Tick(object sender, EventArgs e)
        {
            myCount++;
            Label.Text = myCount.ToString();
        }
    }
Run Code Online (Sandbox Code Playgroud)

c#

3
推荐指数
1
解决办法
2413
查看次数

标签 统计

c# ×1