/[gr2lib]/trunk/gr2lib/core/helpers/arraytostring.cs
ViewVC logotype

Contents of /trunk/gr2lib/core/helpers/arraytostring.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 96 - (show annotations) (download)
Sat Jul 17 05:11:13 2010 UTC (9 years, 1 month ago) by william
File size: 1130 byte(s)
bulk commit:

*Update structs to use simple datatypes
*Add new Classes, etc, etc

1 using System;
2 using System.Collections.Generic;
3 using System.Collections;
4 using System.Text;
5
6 namespace gr2lib.core.helpers
7 {
8 /// <summary>
9 /// Converts an array to a string representation
10 /// </summary>
11 /// <typeparam name="E">Element Type</typeparam>
12 /// <typeparam name="T">Array Type</typeparam>
13 public class arraytostring<E, A>
14 where A : IEnumerable<E>
15 where E : IConvertible
16 {
17
18 private int ConvertType(E value)
19 {
20 try
21 {
22 return Convert.ToInt32(value.ToString(),10);
23 }
24 catch
25 {
26 return Convert.ToInt32(value.ToString(), 16);
27 }
28
29 }
30
31 private string _array_string = "";
32 public arraytostring(A array) { int i = 0; foreach (E e in array) { if (i == 0) { _array_string = _array_string + "0x" + ConvertType(e).ToString("X8"); } else { _array_string = _array_string + " " + "0x" + ConvertType(e).ToString("X8"); } i++; } }
33 public override string ToString() { return _array_string; }
34 }
35 }

  ViewVC Help
Powered by ViewVC 1.1.22