How to enumerate all values of an enum in C#?
Hello everyone! I just started learning C# and encountered a problem. I have an enum, for example:\n\n```csharp\nenum DaysOfWeek\n{\n Monday,\n Tuesday,\n Wednesday,\n Thursday,\n Friday,\n Saturday,\n Sunday\n}\n```\n\nI need to output all days of the week to the console or use them in a loop. I understand how to work with arrays and lists, but I'm confused with enum. I tried writing something like:\n\n```csharp\nforeach (var day in DaysOfWeek)\n{\n Console.WriteLine(day);\n}\n```\n\nBut the compiler gives an error: "foreach cannot operate on a 'type'". I googled it, and people say I need to use `Enum.GetValues`, but I don't fully understand how it works. Please tell me how to properly iterate over all enum values? And is it possible to get their count? I would be grateful for any help.