It has been a long time since the question was asked and this may help somebody looking for an answer in the future.
Let's say you give your user the ability to show or hide columns in a grid and you want to persist those settings without lots of individual settings being persisted.
Saving a value of 3 to persisant storage allows you to retrieve a single value from that storage but be able to set multiple values from that single number.
An example being
var columnsVisibity = (SearchResultsColumnOptions)3; //this number has been retieved from persistant storage
SearchResultsGrid.Columns[0].Visible = columnsVisibity.HasFlag(SearchResultsColumnOptions.Artist);
SearchResultsGrid.Columns[1].Visible = columnsVisibity.HasFlag(SearchResultsColumnOptions.Title);
SearchResultsGrid.Columns[2].Visible = columnsVisibity.HasFlag(SearchResultsColumnOptions.Disc);
[Flags]
public enum SearchResultsColumnOptions:byte
{
None = 0b000,
Artist = 0b001,
Title = 0b010,
Disc = 0b100,
All = 0b111
}
The result of this example would be that the disc column would not be visible.
I hope this helps somebody as have tried to make this a simple example as possible.