Line | |
---|
1 | namespace Push.Data {
|
---|
2 | using System.Linq;
|
---|
3 |
|
---|
4 | public static class ExampleConverter {
|
---|
5 | private const char ArrayValueSeparator = ' ';
|
---|
6 |
|
---|
7 | private static readonly char[] arraySymbolTrim = { '[', ']' };
|
---|
8 |
|
---|
9 | public static long Integer(string str) {
|
---|
10 | return long.Parse(str);
|
---|
11 | }
|
---|
12 |
|
---|
13 | public static long[] Integers(string str) {
|
---|
14 | var values =
|
---|
15 | str.Trim(arraySymbolTrim).Split(ArrayValueSeparator).Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
|
---|
16 |
|
---|
17 | var result = new long[values.Count];
|
---|
18 |
|
---|
19 | for (var i = 0; i < result.Length; i++) result[i] = Integer(values[i]);
|
---|
20 |
|
---|
21 | return result;
|
---|
22 | }
|
---|
23 | }
|
---|
24 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.