Закрывается консоль - C#
Формулировка задачи:
Если внутри метода создаю любой элемент на основе класса (пробовал random и webclient) консоль просто закрывается (без ошибок). Что за дичь?
Решение задачи: «Закрывается консоль»
textual
Листинг программы
using System;
using System.Security.Cryptography;
using System.Text;
public static class Commands
{
public static void rndint (string s)
{
string[] a = s.Split(',');
int x = Convert.ToInt32(a[0]);
int y = Convert.ToInt32(a[1]);
Random rnd = new Random();
Console.WriteLine(rnd.Next(x, y));
}
public static void exit(string s)
{
if (s == "0")
{
Environment.Exit(0);
}
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("GoodBye!");
Console.ForegroundColor = ConsoleColor.Yellow;
string str = "Press any key to exit...";
Console.WriteLine(str);
Console.ReadKey();
Environment.Exit(0);
}
public static void sha1(string s)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("SHA1: {0}", CommandSystem.SHA1(s));
}
public static void md5(string s)
{
Console.ForegroundColor = ConsoleColor.Green;
MD5 md5 = new MD5CryptoServiceProvider();
byte[] checkSum = md5.ComputeHash(Encoding.UTF8.GetBytes(s));
string result = BitConverter.ToString(checkSum).Replace("-", String.Empty);
Console.WriteLine("MD5: {0}", result);
}
public static void print(string s)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(s);
}
public static void block(string s)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Locked!");
Program.isLock = true;
}
public static void clear(string s)
{
Console.Clear();
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Command line parcer v0.1");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(DateTime.Now);
}
public static void settitle(string title)
{
Console.Title = title;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("OK!");
}
public static void help(string s)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Help for CommandLine");
}
public static void gettime(string s)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(DateTime.Now);
}
}