I have the following enum with flags:
[Flags]
public enum DataFiat {
  Public = 1,
  Listed = 2,
  Client = 4
} // DataFiat
And I have an int array, for example:
int[] selected = new int[] { 1, 4 }
How can I convert this to my enum which would become:
DataFiat.Public | DataFiat.Client
Thank You, Miguel
var f = (DataFiat)selected.Sum();
                        How about something like
var tt = (DataFiat)selected.Aggregate((i, t) => i | t);
                        this snippet:
        var intArr = new[] { 1, 4 };
        var sum = intArr.Sum(x => x);
        var result = (Test)sum;
returns

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With