经验36--C#无名(大事,物...)

it2025-07-07  14

有时候,方便代码,它会使用匿名的东西。

1、匿名事件

args.CookieGot += (s, e) =>                 {                     this.IsWebLogon = true;                 };

不用专门再去写方法,当然这样的方式简单介绍的时候使用。

2、匿名对象

var ohList = ohManager.GetList().Select(x => new { x.ID, x.Name,x.CreateTime });

用户接口或前后台交互,指定某些字段,且新的对象,不用再去建实体。

3、匿名Form线程

this.Invoke(new Action(() =>             {                 Btc38ImageForm form = new Btc38ImageForm();                 form.ShowDialog();             }));

防止影响主form。不会卡。

4、匿名线程

Thread t = new Thread(() =>             {                 Runing();             });             t.IsBackground = true;//程序关闭。线程关闭             t.Start();

5、匿名timer

timer = new System.Timers.Timer(1 * 1000);                 timer.Elapsed += (s, e) => {                     d1.Runing();                     d15.Runing();                 };                 timer.AutoReset = true;                 timer.Enabled = true;                 timer.Start();

分类似匿名事件。

版权声明:本文博主原创文章,博客,未经同意不得转载。

转载于:https://www.cnblogs.com/bhlsheji/p/4886328.html

相关资源:数据结构—成绩单生成器
最新回复(0)