V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
placeholder
V2EX  ›  C#

抄来的 csharp 代码,我想分开写它需要的参数,结果给自己写麻了

  •  
  •   placeholder · 2022-09-04 02:26:46 +08:00 · 1737 次点击
    这是一个创建于 572 天前的主题,其中的信息可能已经有所发展或是发生改变。
     DispatcherTimer timer = new DispatcherTimer(new TimeSpan(0, 0, 0, 0, 1), DispatcherPriority.Loaded, delegate { dateText.Content = DateTime.Now.ToString("HH:mm:ss fff"); }, this.Dispatcher);
    

    就是这句,我想把其中的 delegate 单独摘出来写完再填进去,能实现吗?

    2 条回复    2022-09-04 12:52:43 +08:00
    iold
        1
    iold  
       2022-09-04 10:54:35 +08:00   ❤️ 1
    当然可以了...,你上面的用法相当一个无参无返回值的委托(你的方法满足这个条件就可以)。
    我觉得你还是看看官方文档,有助于你全面了解 c#的委托。
    https://docs.microsoft.com/zh-cn/dotnet/csharp/programming-guide/delegates/using-delegates
    placeholder
        2
    placeholder  
    OP
       2022-09-04 12:52:43 +08:00
    @iold 好的,我努力
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5883 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 02:15 · PVG 10:15 · LAX 19:15 · JFK 22:15
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.