-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.cs
58 lines (47 loc) · 1.58 KB
/
common.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
50
51
52
53
54
55
56
57
58
namespace Treblecross
{
public static class Common<T>
{
public static T[] Convert1dArray(T[,] array){
T[] ret = new T[array.GetLength(1)];
for (int j = 0; j < array.GetLength(1); j++) {
ret[j] = array[0, j];
}
return ret;
}
public static List<List<T>> Convert2DArrayTo2DList(T[,] ary2D) {
List<List<T>> list2D =new List<List<T>>();
for (int i = 0; i < ary2D.GetLength(0); i++) {
List<T> innerList = new List<T>();
for (int j = 0; j < ary2D.GetLength(1); j++)
{
innerList.Add(ary2D[i, j]);
}
list2D.Add(innerList);
}
return list2D;
}
}
public static class Log
{
public static void Info(string msg)
{
Info("System", msg);
}
public static void Info(string tag, string msg) {
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("[{0}] {1}", tag, msg);
Console.ResetColor();
}
public static void Warning(string msg) {
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine("[System] {0}", msg);
Console.ResetColor();
}
public static void Error(string msg, Exception ex) {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("[System] {0}, Error: {1}", msg, ex.Message);
Console.ResetColor();
}
}
}