请问C#包括有限状态机? [英] Does C# include finite state machines?
问题描述
我最近看了关于的boost ::状态图
库(有限状态机),我喜欢这个概念。
I've recently read about the boost::statechart
library (finite state machines) and I loved the concept.
C#有类似的机制? ?还是可以使用特定的设计模式实施
Does C# have a similar mechanism ? Or can it be implemented using a specific design pattern?
推荐答案
是的,C#具有的迭代器块这是编译器生成的状态机。
Yes, C# has iterator blocks which are compiler-generated state machines.
如果你想实现你自己的状态机,你可以创建的的IEnumerable<定制实现; T>
和的IEnumerator< T>
接口
If you wish to implement you own state machine you can create custom implementations of the IEnumerable<T>
and IEnumerator<T>
interfaces.
这两种方法都突出了.NET框架的实施的 Iterator模式。
Both of these approaches highlight the .NET framework's implementation of the iterator pattern.
这篇关于请问C#包括有限状态机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!