使用静态类的构造函数,保证某些操作在整个程序运行过程中只运行一次

问题: 有一些初始化操作,需要在整个程序运行过程中,只运行一次。除了使用单例模式,或者在 Main() 中实现,还有其他方法么? 比如,有一个任务处理程序,每次点击Run按钮,程序就会调用一个静态类StepsProcessor.cs中的ProcessSteps()方法依次对指定的任务列表进行处理。这个静态类会发布三个事件: 开始执行任务列表 全部任务执行成功 某个任务执... [More]

C#: Get a random string

Background: Sometimes, we need to generate some random strings for testing purpose. When I met this situation, I was surprised that C# has no such built-in methods inside its Random Class. So I had t... [More]

An extension for C# built-in Random class

For testing purpose, I need to generate some random string (contains only letters without any other special characters) with customized length. So I extends the C# built-in Random class like this: #r... [More]