-
Notifications
You must be signed in to change notification settings - Fork 0
/
SampleClass.cs
44 lines (38 loc) · 1.29 KB
/
SampleClass.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
using System;
using System.Globalization;
using System.Threading;
namespace SampleLib
{
public static class SampleClass
{
public static int Method(string[] args)
{
if (args == null)
throw new ArgumentNullException(nameof(args));
Console.WriteLine($"{nameof(Method)}({string.Join(", ", args)})");
int result = 0;
for (int i = 0; i < args.Length; i++)
{
if (args[i] == "crash")
{
Environment.Exit(666);
}
if (args[i] == "throw")
{
throw new Exception("Exception forced by arguments");
}
if (args[i].StartsWith("sleep", StringComparison.Ordinal))
{
int value = int.Parse(args[i].Substring("sleep".Length), CultureInfo.InvariantCulture);
Thread.Sleep(value);
}
if (args[i].StartsWith("return", StringComparison.Ordinal))
{
result = int.Parse(args[i].Substring("return".Length), CultureInfo.InvariantCulture);
}
}
Console.WriteLine($"{nameof(Method)} = {result}");
return 0;
}
}
}