C#是否包含有限状态机? [英] Does C# include finite state machines?
本文介绍了C#是否包含有限状态机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
boost :: statechart
库(有限状态机),我喜欢这个概念。 C#有类似的机制吗?或者可以使用特定的设计模式实现?
解决方案
是的,C#有迭代器块。
如果您希望实现自己的状态机,您可以创建 IEnumerable< T>
和 IEnumerator< T>
接口。
这两种方法都突出了.NET框架的迭代器模式。
I've recently read about the boost::statechart
library (finite state machines) and I loved the concept.
Does C# have a similar mechanism ? Or can it be implemented using a specific design pattern?
解决方案
Yes, C# has iterator blocks which are compiler-generated state machines.
If you wish to implement you own state machine you can create custom implementations of the IEnumerable<T>
and IEnumerator<T>
interfaces.
Both of these approaches highlight the .NET framework's implementation of the iterator pattern.
这篇关于C#是否包含有限状态机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文