我有一个string可以是“0”或“1”,并且保证不会是其他任何东西。
string
所以问题是:将其转换为最佳、最简单和最优雅的方法是什么?bool?
bool
确实很简单:
bool b = str == "1";