I'm trying to get a List of strings of the values of an Flags Enum
I have two enums
enum example {
name0 = 0,
name1 = 1,
name2 = 2,
name3 = 3
}
//And a flagged enum
[Flags]
enum example2 {
none = 0,
name1 = 1 <<example.name1,
name2 = 1 << example.name2,
name3 = 1 << example.name3
}
I have a flagged enum setted.
example2 = name1 | name2;
What I'm trying to do, is, from that example2 = name1 | 2; get a List of strings that has the integer values of the first enum.
So far I've tried to make a List of strings of the flagged enum: example:
example2.toString()
//result: "name1, name2"
//I'm not quite sure how to proceed with this, I've read the documentation but can't find something helpful, probably to split and trim the string to get a list of names, then iterate over that list and somehow get the numeric value using the names
/*
result I'm trying to achieve:
["1", "2"] <-- List of strings of int values corresponding to those names.
*/
Does anyone know a good way to do this?
~This is my first question, sorry if the explanation was bad.