-
Notifications
You must be signed in to change notification settings - Fork 1
/
Helper.cs
51 lines (42 loc) · 1.33 KB
/
Helper.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ndot
{
public static class Helper
{
public static string GetExceptionRecur(this Exception e)
{
var msg = e;
string buf = msg.Message + " ";
while (msg != null)
{
msg = msg.InnerException;
if (msg != null)
buf += msg.Message + " ";
}
return buf;
}
public static byte[] Rev(this byte[] src)
{
Array.Reverse(src);
return src;
}
static Encoding urf8encoder = Encoding.UTF8;
public static byte[] UTF8Encode(this string s) => urf8encoder.GetBytes(s);
public static string UTF8Decode(this byte[] s) => urf8encoder.GetString(s);
public static string Print<T>(this ICollection<T> collection, string div)
{
if (collection == null || collection.Count == 0)
return String.Empty;
string buf = collection.First().ToString();
for (int i = 1; i < collection.Count; i++)
{
var el = collection.ElementAt(i);
buf += div + el;
}
return buf;
}
}
}