See the below code:
if (pieceName == Piece.PieceType.ANTIDEPRESSANTS.ToString ()) {
return Piece.PieceType.ANTIDEPRESSANTS;
}
There are 10 other types of Piece.PieceType’s. Is it possible to use some kind of for loop to flick through each one? Like this, but functional?
for (int i = 0; i<Piece.PieceType.count; ++i){
if (pieceName == Piece.PieceType*.ToString ()) {*
return Piece.PieceType*;*
}
}
I found [this][1] and [this][2] answer, but I don’t have an Enum class, or a GetValues() function. There’s got to be some way, right?
_[1]: C# Iterating through an enum? (Indexing a System.Array) - Stack Overflow
_[2]: .net - How to loop through all enum values in C#? - Stack Overflow