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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/gr2lib/core/helpers/arraytostring.cs	2010/07/17 05:10:22	95
+++ trunk/gr2lib/core/helpers/arraytostring.cs	2010/07/17 05:11:13	96
@@ -10,10 +10,26 @@
     /// </summary>
     /// <typeparam name="E">Element Type</typeparam>
     /// <typeparam name="T">Array Type</typeparam>
-    public class arraytostring<E, A> where A : IEnumerable<E>
+    public class arraytostring<E, A> 
+        where A : IEnumerable<E>
+        where E : IConvertible
     {
+
+        private int ConvertType(E value)
+        {
+            try
+            {
+                return Convert.ToInt32(value.ToString(),10);
+            }
+            catch
+            {
+                return Convert.ToInt32(value.ToString(), 16);
+            }
+            
+        }
+
         private string _array_string = "";
-        public arraytostring(A array) { int i = 0; foreach (E e in array) { if (i == 0) { _array_string = _array_string + e.ToString(); } else { _array_string = _array_string + " " + e.ToString(); } i++; } }
+        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++; } }
         public override string ToString() { return _array_string; }
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22