The next example is intended to count the amount of flags in the specified flag combination.
The example is provided as a extension method:
<DebuggerStepThrough>
<Extension>
<EditorBrowsable(EditorBrowsableState.Always)>
Public Function CountFlags(ByVal sender As [Enum]) As Integer
Return sender.ToString().Split(","c).Count()
End Function
Usage Example:
Dim flags As FileAttributes = (FileAttributes.Archive Or FileAttributes.Compressed)
Dim count As Integer = flags.CountFlags()
Console.WriteLine(count)