✅ Console Menu Help
Hey all, I'm a very beginner c# hobbyist just need some clarifications on best practice.
Lets say I have a console app with a few different 'menus'. The menus are just text options that are all individualized.
I know I could just WriteLine the strings in Main, ask for a user choice then go into a switch statement.
But, what are my options for making this visually clean?
I currently do is just make a 'SubMenu' class filled with static functions and just put all my menu functions there.
Should I just use regions to hide the menu sections?
Or am I missing something very basic?
5 Replies
$static
In C#, static allows you to have members (classes, methods, etc) that are not tied to any particular instance and are therefore always, globally, accessible. When applying
static
members, take the following considerations:
• If there are to be multiple instances of a class, do not use static
• If you need to track state, do not use static
• If you are going to have multi threaded workflows, do not use static unless you're aware of the caveats
static
is best used for stateless methods, extension methods/classes and in areas where you understand the pros/cons. Read more here: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/static$spectre
Spectre.Console is a .NET library that allows for easy creation of console UIs, text formatting in the console, and command-line argument parsing.
https://spectreconsole.net/
Spectre.Console - Welcome!
Spectre.Console is a .NET library that makes it easier to create beautiful console applications.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.