当前位置:网站首页>C# 1秒跑一个数字的展示,主要练习 事件相关内容
C# 1秒跑一个数字的展示,主要练习 事件相关内容
2022-07-29 12:34:00 【laocooon】
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
namespace EventExample
{
internal class Program
{
static void Main(string[] args)
{
Timer timer = new Timer();//1 拥有者
timer.Interval = 1000;//1秒
Boy boy = new Boy();//3 响应者
//2 事件 Elapsed //4 Action 事件处理器
timer.Elapsed += boy.Action;// 5 订阅
timer.Start();
Console.ReadKey();
}
}
class Boy
{
static int i = 0;
internal void Action(object sender, ElapsedEventArgs e)
{
Console.Write(String.Format($"\r{i++.ToString()}"));
}
}
}
边栏推荐
- 我和 TiDB 的故事 | 缘份在,那就终是能相遇的
- 来自 Qt 官网的呐喊
- [纯理论] YOLOv5
- The interviewer was stunned by the self-growth of 4 mainstream database IDs in one breath
- PD 源码分析- Checker: region 健康卫士
- IDEA2021.2安装与配置(持续更新)
- 什么是DOM
- 金仓数据库KingbaseES客户端编程接口指南-JDBC(2. 概述)
- Mysql进阶优化篇01——四万字详解数据库性能分析工具(深入、全面、详细,收藏备用)
- MySql 5.7.38下载安装教程 ,并实现在Navicat操作MySql
猜你喜欢
随机推荐
CSDN TOP1 "a virgo program ape" how to become a blogger, millions of fans writing
C语言小游戏------贪吃蛇----小白专用
2022 IDEA (学生邮箱认证)安装使用教程以及基础配置教程
What should I do if the webpage is hijacked and redirected?Release net repair method
金仓数据库 KingbaseES 客户端编程接口指南 - ODBC 驱动使用
Bika LIMS 开源LIMS集—— SENAITE的使用(用户、角色、部门)
我和 TiDB 的故事 | 缘份在,那就终是能相遇的
nacos集群搭建
Mysql各个大版本之间的区别
金仓数据库KingbaseES客户端编程接口指南-JDBC(2. 概述)
xxl-job源码解析(技术分享)
Draw boxes of WPF screenshots controls and ellipse (4) "imitation WeChat"
[WeChat applet] One article to solve button, input, image components
shell if else 使用
The interviewer was stunned by the self-growth of 4 mainstream database IDs in one breath
CentOS7安装Oracle数据库的全流程
DVWA full level customs clearance tutorial
SIP system composition format
栈“后进先出”和队列中“先进先出”的含义
The strategy pattern replacement if the else





![[纯理论] FCOS](/img/a4/f4f28faf5764e1fdebd475e445e2b0.png)



