-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRun_Continue.cs
49 lines (40 loc) · 2 KB
/
Run_Continue.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Run/Continue Program Shell Snippet for C#
// Author: Justin P. Dickerson ©2018
using System.Text.RegularExpressions; // Important! Insert statement above the namespace!!!!
/*
Instructions on how to use Snippet
Complete Shell: Program Start, Validated Continue, and Manual Exit and Close with customizable User Input Prompts (UIPs)
1)Copy & Paste the snippet below outside the Main method but within the class Program
2)Then call inside the Main method the RunProgram & ContinueProgram methods in the following order: RunProgram(); ContinueProgram();
OOP Additions: Do this when engaging in OOP!
3) Pass instantiated variable name from the Main method into the RunProgram and ContinueProgram methods located in the Main method
4) Pass instantiated variable name and type from the Main method into RunProgram and ContinueProgram methods
Customization:
1) Console.WriteLine() strings can be customized to fit the needs of the program
2) Code (Particularly non OOP in nature) should go into the RunProgram method under the Console.WriteLine(Input), however it is not necessary
3) Related method calls should go into the RunProgram method, however not required
4) Custom Methods need to be created outside of the Main, RunProgram, and ContinueProgram methods yet inside the Program class
Developer Note: Snippet contains no recursion
*/
public static void RunProgram()
{
Console.WriteLine("Enter Custom Text Here");
string Input = Console.ReadLine();
Console.WriteLine($"Enter Custom Text Here {Input}");
// Code
// Method calls
}
public static void ContinueProgram()
{
Console.WriteLine("Enter Custom Text Here? Y/N");
string Continue = Console.ReadLine();
while (Regex.Match(Continue, @"^[Y|y]$").Success)
{
RunProgram();
Continue = "";
Console.WriteLine("Enter Custom Text Here? Y/N");
Continue = Console.ReadLine();
}
Console.WriteLine("Enter Custom Text Here");
Console.ReadLine();
}