C# – Convert list to array

The simplest way to convert a list to an array is to use the List.ToArray() method: This outputs the following: Internally, the List<T> class stores elements in a dynamically sized array (it resizes when necessary). So under the hood, List.ToArray() uses Array.Copy() to copy the list’s internal array to a new array. This is very … Read more

C# – Parsing commands and arguments in a console app

In a console app there are two ways to get commands: After getting a command, you have to parse it to figure out what code to execute. Typically commands have the following format: commandName -argumentName argumentValue. For example, take a look at this familiar git command: This is passing the command line arguments into the … Read more