Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/battousai999/consoleutils
Some utility functions useful when writing prototype console applications.
https://github.com/battousai999/consoleutils
console utility-library
Last synced: 10 days ago
JSON representation
Some utility functions useful when writing prototype console applications.
- Host: GitHub
- URL: https://github.com/battousai999/consoleutils
- Owner: battousai999
- Created: 2017-10-27T18:59:33.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-09-17T14:56:28.000Z (2 months ago)
- Last Synced: 2024-11-03T23:07:47.093Z (14 days ago)
- Topics: console, utility-library
- Language: C#
- Homepage:
- Size: 45.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ConsoleUtils
This library is composed of a collection of helper methods that I use when creating prototype console applications for experimenting with code.Typically when I used this library in an experiment, I will include the library with a static using statement (so that I don't have to qualify the helper methods in the library with "ConsoleUtils.").
``` C#
using static Battousai.Utils.ConsoleUtils;
```I use the RunLoggingExceptions() method to wrap around the experimental code, catching any exceptions (logging the exception's stack trace to the console) and injecting a "Press enter key to continue" (since I'll typically be running the code in Visual Studio, and otherwise the console in which the results are displayed closes before I can see the results). I also use the Log() method as a shortcut replacement for Console.WriteLine().
For example:
``` C#
using System;
using System.Collections.Generic;
using System.Linq;
using static Battousai.Utils.ConsoleUtils;namespace TestConsoleApp
{
class Program
{
static void Main(string[] args)
{
RunLoggingExceptions(() =>
{
var list1 = new List { 1, 2, 3, 4, 1, 2, 3, 4 };
var list2 = new List { 4 };Log("Does the LINQ Except method treat the lists as sets?");
Log("(That is, do the results only contain distinct elements?)");
Log();var results = list1.Except(list2).ToList();
Log("Results = " + String.Join(", ", results));
},
true);
}
}
}
```The library also contains some other helper methods for things such as measuring duration and iterating actions.