placeholder
V2EX  ›  C#

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

  •  
  •   placeholder · Sep 4, 2022 · 2494 views
    This topic created in 1347 days ago, the information mentioned may be changed or developed.
     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 replies    2022-09-04 12:52:43 +08:00
    iold
        1
    iold  
       Sep 4, 2022   ❤️ 1
    当然可以了...,你上面的用法相当一个无参无返回值的委托(你的方法满足这个条件就可以)。
    我觉得你还是看看官方文档,有助于你全面了解 c#的委托。
    https://docs.microsoft.com/zh-cn/dotnet/csharp/programming-guide/delegates/using-delegates
    placeholder
        2
    placeholder  
    OP
       Sep 4, 2022
    @iold 好的,我努力
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5644 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 03:38 · PVG 11:38 · LAX 20:38 · JFK 23:38
    ♥ Do have faith in what you're doing.