public static void showInt() { short a = 0; ushort b = 0; int c = 0; uint d = 0; long e = 0L; ulong f = 0L; Int16 g = 0; Int32 h = 0; Int64 i = 0; UInt16 j = 0; UInt32 k = 0; UInt64 l = 0; Console.WriteLine(a.GetType()); Console.WriteLine(b.GetType()); Console.WriteLine(c.GetType()); Console.WriteLine(d.GetType()); Console.WriteLine(e.GetType()); Console.WriteLine(f.GetType()); Console.WriteLine(g.GetType()); Console.WriteLine(h.GetType()); Console.WriteLine(i.GetType()); Console.WriteLine(j.GetType()); Console.WriteLine(k.GetType()); Console.WriteLine(l.GetType()); }
UInt64 compareUint64(UInt64 b, UInt64 b2) { if (b == b2) { return(b); } throw new IllegalStateException("Not got expected value for type: " + b2.GetType().ToString()); }
public static void Main() { Double[] values = { Double.MinValue, -67890.1234, -12345.6789, 12345.6789, 67890.1234, Double.MaxValue, Double.NaN, Double.PositiveInfinity, Double.NegativeInfinity }; checked { foreach (var value in values) { try { Int64 lValue = (long)value; Console.WriteLine("{0} ({1}) --> {2} (0x{2:X16}) ({3})", value, value.GetType().Name, lValue, lValue.GetType().Name); } catch (OverflowException) { Console.WriteLine("Unable to convert {0} to Int64.", value); } try { UInt64 ulValue = (ulong)value; Console.WriteLine("{0} ({1}) --> {2} (0x{2:X16}) ({3})", value, value.GetType().Name, ulValue, ulValue.GetType().Name); } catch (OverflowException) { Console.WriteLine("Unable to convert {0} to UInt64.", value); } try { Decimal dValue = (decimal)value; Console.WriteLine("{0} ({1}) --> {2} ({3})", value, value.GetType().Name, dValue, dValue.GetType().Name); } catch (OverflowException) { Console.WriteLine("Unable to convert {0} to Decimal.", value); } try { Single sValue = (float)value; Console.WriteLine("{0} ({1}) --> {2} ({3})", value, value.GetType().Name, sValue, sValue.GetType().Name); } catch (OverflowException) { Console.WriteLine("Unable to convert {0} to Single.", value); } Console.WriteLine(); } } }
public void TestUInt64() { FileStream stream = new FileStream("Prova.bin", System.IO.FileMode.Create); CompactFormatter CFormatter = new CompactFormatter(); long start = DateTime.Now.Ticks; UInt64[] s = new UInt64[max]; s[0] = 0; Console.WriteLine( "Serializing and Deserializing an array of type {1} composed by {0} elements", max, s.GetType().ToString() ); for (int i = 1; i < max; i++) { //Console.WriteLine("Serialized {0}",s); s[i] = s[i - 1] + 1; } CFormatter.Serialize(stream, s); stream.Flush(); stream.Close(); stream = new FileStream("Prova.bin", System.IO.FileMode.Open); CompactFormatter CFormatter2 = new CompactFormatter(); UInt64[] temp = new UInt64[max]; //for(int i = 0; i<max; i++) //{ temp = (UInt64[])CFormatter2.Deserialize(stream); //} stream.Close(); long stop = DateTime.Now.Ticks; long ts = stop - start; Console.WriteLine("Elapsed Time:{0},{1},{2}", ts, start, stop); UInt64 s2 = 0; for (int i = 0; i < max; i++) { //Console.WriteLine("Deserialized {0}",temp[i]); Assert.AreEqual(temp[i], s2); s2++; } }
public static void Main() { UInt64 value1 = 50; UInt64 value2 = 50; // Display the values. Console.WriteLine("value1: Type: {0} Value: {1}", value1.GetType().Name, value1); Console.WriteLine("value2: Type: {0} Value: {1}", value2.GetType().Name, value2); // Compare the two values. Console.WriteLine("value1 and value2 are equal: {0}", value1.Equals(value2)); }
public void TestUInt64() { FileStream stream = new FileStream("Prova.bin", System.IO.FileMode.Create); CompactFormatter CFormatter = new CompactFormatter(); long start = DateTime.Now.Ticks; UInt64 s = 0; Console.WriteLine( "Serializing and Deserializing {0} instances of type {1}", max, s.GetType().ToString() ); for (int i = 0; i < max; i++) { CFormatter.Serialize(stream, s); //Console.WriteLine("Serialized {0}",s); s++; } stream.Flush(); stream.Close(); stream = new FileStream("Prova.bin", System.IO.FileMode.Open); CompactFormatter CFormatter2 = new CompactFormatter(); UInt64[] temp = new UInt64[max]; for (int i = 0; i < max; i++) { temp[i] = (UInt64)CFormatter2.Deserialize(stream); } stream.Close(); long stop = DateTime.Now.Ticks; long ts = stop - start; Console.WriteLine("Elapsed Time:{0},{1},{2}", ts, start, stop); s = 0; for (int i = 0; i < max; i++) { //Console.WriteLine("Deserialized {0}",temp[i]); Assert.AreEqual(temp[i], s); s++; } }
public static void Main() { object[] values = { (short)10, (short)20, 10, 20, 10L, 20L, 10D, 20D,(ushort)10, (ushort)20, 10U, 20U, 10ul, 20ul }; UInt64 baseValue = 20; String baseType = baseValue.GetType().Name; foreach (var value in values) { Console.WriteLine("{0} ({1}) = {2} ({3}): {4}", baseValue, baseType, value, value.GetType().Name, baseValue.Equals(value)); } }
public void Convert_PrimitiveDatatypeToString_Test() { { Boolean t1 = true; var SPV = new SettingsPropertyValue(new SettingsProperty("whatever", t1.GetType(), null)); SPV.PropertyValue = t1; SPV.SerializedValue.Should().Be("True"); } { Byte t1 = 5; var SPV = new SettingsPropertyValue(new SettingsProperty("whatever", t1.GetType(), null)); SPV.PropertyValue = t1; SPV.SerializedValue.Should().Be("5"); } { SByte t1 = 5; var SPV = new SettingsPropertyValue(new SettingsProperty("whatever", t1.GetType(), null)); SPV.PropertyValue = t1; SPV.SerializedValue.Should().Be("5"); } { Int16 t1 = 5; var SPV = new SettingsPropertyValue(new SettingsProperty("whatever", t1.GetType(), null)); SPV.PropertyValue = t1; SPV.SerializedValue.Should().Be("5"); } { UInt16 t1 = 5; var SPV = new SettingsPropertyValue(new SettingsProperty("whatever", t1.GetType(), null)); SPV.PropertyValue = t1; SPV.SerializedValue.Should().Be("5"); } { Int32 t1 = 5; var SPV = new SettingsPropertyValue(new SettingsProperty("whatever", t1.GetType(), null)); SPV.PropertyValue = t1; SPV.SerializedValue.Should().Be("5"); } { UInt32 t1 = 5; var SPV = new SettingsPropertyValue(new SettingsProperty("whatever", t1.GetType(), null)); SPV.PropertyValue = t1; SPV.SerializedValue.Should().Be("5"); } { Int64 t1 = 5; var SPV = new SettingsPropertyValue(new SettingsProperty("whatever", t1.GetType(), null)); SPV.PropertyValue = t1; SPV.SerializedValue.Should().Be("5"); } { UInt64 t1 = 5; var SPV = new SettingsPropertyValue(new SettingsProperty("whatever", t1.GetType(), null)); SPV.PropertyValue = t1; SPV.SerializedValue.Should().Be("5"); } { Char t1 = '5'; var SPV = new SettingsPropertyValue(new SettingsProperty("whatever", t1.GetType(), null)); SPV.PropertyValue = t1; SPV.SerializedValue.Should().Be("5"); } { Double t1 = 1.79; var SPV = new SettingsPropertyValue(new SettingsProperty("whatever", t1.GetType(), null)); SPV.PropertyValue = t1; SPV.SerializedValue.Should().Be("1.79"); } { Single t1 = 1.79f; var SPV = new SettingsPropertyValue(new SettingsProperty("whatever", t1.GetType(), null)); SPV.PropertyValue = t1; SPV.SerializedValue.Should().Be("1.79"); } { Decimal t1 = 1.79M; var SPV = new SettingsPropertyValue(new SettingsProperty("whatever", t1.GetType(), null)); SPV.PropertyValue = t1; SPV.SerializedValue.Should().Be("1.79"); } { string t1 = null; var SPV = new SettingsPropertyValue(new SettingsProperty("whatever", typeof(string), null)); SPV.PropertyValue = t1; SPV.SerializedValue.Should().BeNull(); } { string t1 = ""; var SPV = new SettingsPropertyValue(new SettingsProperty("whatever", t1.GetType(), null)); SPV.PropertyValue = t1; SPV.SerializedValue.Should().Be(""); } { string t1 = "foo"; var SPV = new SettingsPropertyValue(new SettingsProperty("whatever", t1.GetType(), null)); SPV.PropertyValue = t1; SPV.SerializedValue.Should().Be("foo"); } }
public void Save(String PropertyName, UInt64 Value) { _GameSaver.CreateChildElement(_Element, PropertyName, Value.GetType(), Value.ToString(_GameSaver.CultureInfo)); }
static void Main(string[] args) { int int1 = 3; Int32 int2 = 4; Console.WriteLine(int1.GetType()); Console.WriteLine(int2.GetType()); Console.WriteLine(); bool bool1 = true; Boolean bool2 = false; Console.WriteLine(bool1.GetType()); Console.WriteLine(bool2.GetType()); Console.WriteLine(); byte byte1 = 1; Byte byte2 = 2; Console.WriteLine(byte1.GetType()); Console.WriteLine(byte2.GetType()); Console.WriteLine(); sbyte sbyte1 = 1; SByte sbyte2 = 2; Console.WriteLine(sbyte1.GetType()); Console.WriteLine(sbyte2.GetType()); Console.WriteLine(); short short1 = 1; Int16 short2 = 2; Console.WriteLine(short1.GetType()); Console.WriteLine(short2.GetType()); Console.WriteLine(); ushort ushort1 = 1; UInt16 ushort2 = 2; Console.WriteLine(ushort1.GetType()); Console.WriteLine(ushort2.GetType()); Console.WriteLine(); uint uint1 = 1; UInt32 uint2 = 2; Console.WriteLine(uint1.GetType()); Console.WriteLine(uint2.GetType()); Console.WriteLine(); long long1 = 1; Int64 long2 = 2; Console.WriteLine(long1.GetType()); Console.WriteLine(long2.GetType()); Console.WriteLine(); ulong ulong1 = 1; UInt64 ulong2 = 2; Console.WriteLine(ulong1.GetType()); Console.WriteLine(ulong2.GetType()); Console.WriteLine(); float float1 = 1.1f; Single float2 = 2.2f; Console.WriteLine(float1.GetType()); Console.WriteLine(float2.GetType()); Console.WriteLine(); double double1 = 1.1; Double double2 = 2.2; Console.WriteLine(double1.GetType()); Console.WriteLine(double2.GetType()); Console.WriteLine(); decimal decimal1 = 1.1m; Decimal decimal2 = 2.2m; Console.WriteLine(decimal1.GetType()); Console.WriteLine(decimal2.GetType()); Console.WriteLine(); char char1 = 'a'; Char char2 = 'b'; Console.WriteLine(char1.GetType()); Console.WriteLine(char2.GetType()); Console.WriteLine(); string string1 = "AAA"; String string2 = "BBB"; Console.WriteLine(string1.GetType()); Console.WriteLine(string2.GetType()); Console.WriteLine(); object object1 = new object(); Object object2 = new Object(); Console.WriteLine(object1.GetType()); Console.WriteLine(object2.GetType()); Console.WriteLine(); //explicit type conversion int1 = 42; long1 = int1; // conversion int to long short1 = 3; float1 = short1; //conversion shot to float string1 = "Test"; object1 = string1; //conversion string to object //implicit type conversion int2 = (int)long1; // conversion long to int short2 = (short)float1; //conversion float to short string2 = (string)object1; //conversion object to string decimal1 = 23.123m; object2 = decimal1; //boxing decimal2 = (decimal)object2; //unboxing Console.ReadKey(); }
static void Main(string[] args) { sbyte sb1 = 3; SByte sb2 = 3; Console.WriteLine(sb1.GetType()); Console.WriteLine(sb2.GetType()); byte b1 = 3; Byte b2 = 3; Console.WriteLine(b1.GetType()); Console.WriteLine(b2.GetType()); short s1 = 3; Int16 s2 = 3; Console.WriteLine(s1.GetType()); Console.WriteLine(s2.GetType()); ushort us1 = 3; UInt16 us2 = 3; Console.WriteLine(us1.GetType()); Console.WriteLine(us2.GetType()); int i1 = 3; Int32 i2 = 3; Console.WriteLine(i1.GetType()); Console.WriteLine(i2.GetType()); uint ui1 = 3; UInt32 ui2 = 3; Console.WriteLine(ui1.GetType()); Console.WriteLine(ui2.GetType()); long l1 = 3; Int64 l2 = 3; Console.WriteLine(l1.GetType()); Console.WriteLine(l2.GetType()); ulong ul1 = 3; UInt64 ul2 = 3; Console.WriteLine(ul1.GetType()); Console.WriteLine(ul2.GetType()); float f1 = 3.0f; Single f2 = 3.0f; Console.WriteLine(f1.GetType()); Console.WriteLine(f2.GetType()); double d1 = 3.0d; Double d2 = 3.0d; Console.WriteLine(d1.GetType()); Console.WriteLine(d2.GetType()); decimal dl1 = 3.0m; Decimal dl2 = 3.0m; Console.WriteLine(dl1.GetType()); Console.WriteLine(dl2.GetType()); char ch1 = 'A'; Char ch2 = 'B'; Console.WriteLine(ch1.GetType()); Console.WriteLine(ch2.GetType()); string st1 = "str"; String st2 = "str"; Console.WriteLine(st1.GetType()); Console.WriteLine(st2.GetType()); object o1 = 3; Object o2 = 3; Console.WriteLine(o1.GetType()); Console.WriteLine(o2.GetType()); Console.Read(); }
static void Main(string[] args) { bool a1 = true; Boolean a2 = true; byte b1 = 1; Byte b2 = 2; char c1 = '%'; Char c2 = '&'; decimal d1 = 10; Decimal d2 = 10; sbyte sb1 = 1; SByte sb2 = -15; float fl1 = 4.5f; Single fl2 = 4.6f; double db1 = 55.55; Double db2 = 55.66; short sh1 = 1; Int16 sh2 = 1; ushort ush1 = 10; UInt16 ush2 = 10; int i1 = 5; Int32 i2 = 5; uint ui1 = 5000; UInt32 ui2 = 5000; long l1 = 155; Int64 l2 = 156; ulong ul1 = 500; UInt64 ul2 = 501; object ob1 = 500; Object ob2 = 500; string str1 = "stroka"; String str2 = "stroka2"; Console.WriteLine("Variable type: " + a1.GetType()); Console.WriteLine("Variable type: " + a2.GetType()); Console.WriteLine("Variable type: " + b1.GetType()); Console.WriteLine("Variable type: " + b2.GetType()); Console.WriteLine("Variable type: " + c1.GetType()); Console.WriteLine("Variable type: " + c2.GetType()); Console.WriteLine("Variable type: " + d1.GetType()); Console.WriteLine("Variable type: " + d2.GetType()); Console.WriteLine("Variable type: " + sb1.GetType()); Console.WriteLine("Variable type: " + sb2.GetType()); Console.WriteLine("Variable type: " + fl1.GetType()); Console.WriteLine("Variable type: " + fl2.GetType()); Console.WriteLine("Variable type: " + db1.GetType()); Console.WriteLine("Variable type: " + db2.GetType()); Console.WriteLine("Variable type: " + sh1.GetType()); Console.WriteLine("Variable type: " + sh2.GetType()); Console.WriteLine("Variable type: " + ush1.GetType()); Console.WriteLine("Variable type: " + ush2.GetType()); Console.WriteLine("Variable type: " + i1.GetType()); Console.WriteLine("Variable type: " + i2.GetType()); Console.WriteLine("Variable type: " + ui1.GetType()); Console.WriteLine("Variable type: " + ui2.GetType()); Console.WriteLine("Variable type: " + l1.GetType()); Console.WriteLine("Variable type: " + l2.GetType()); Console.WriteLine("Variable type: " + ul1.GetType()); Console.WriteLine("Variable type: " + ul2.GetType()); Console.WriteLine("Variable type: " + ob1.GetType()); Console.WriteLine("Variable type: " + ob2.GetType()); Console.WriteLine("Variable type: " + str1.GetType()); Console.WriteLine("Variable type: " + str2.GetType()); Console.ReadKey(); }
static void Main(string[] args) { sbyte example1 = 1; Console.WriteLine(example1.GetType()); SByte example2 = 1; Console.WriteLine(example2.GetType()); short example3 = 1; Console.WriteLine(example3.GetType()); Int16 example4 = 1; Console.WriteLine(example4.GetType()); int example5 = 1; Console.WriteLine(example5.GetType()); Int32 example6 = 1; Console.WriteLine(example6.GetType()); long example7 = 1; Console.WriteLine(example7.GetType()); Int64 example8 = 1; Console.WriteLine(example8.GetType()); byte example9 = 1; Console.WriteLine(example9.GetType()); Byte example10 = 1; Console.WriteLine(example10.GetType()); ushort example11 = 1; Console.WriteLine(example11.GetType()); UInt16 example12 = 1; Console.WriteLine(example12.GetType()); char example13 = '1'; Console.WriteLine(example13.GetType()); Char example14 = '1'; Console.WriteLine(example14.GetType()); uint example15 = 1; Console.WriteLine(example15.GetType()); UInt32 example16 = 1; Console.WriteLine(example16.GetType()); ulong example17 = 1; Console.WriteLine(example17.GetType()); UInt64 example18 = 1; Console.WriteLine(example18.GetType()); float example19 = 1; Console.WriteLine(example19.GetType()); Single example20 = 1; Console.WriteLine(example20.GetType()); double example21 = 1; Console.WriteLine(example21.GetType()); Double example22 = 1; Console.WriteLine(example22.GetType()); decimal example23 = 1; Console.WriteLine(example23.GetType()); Decimal example24 = 1; Console.WriteLine(example24.GetType()); }
static void Main(string[] args) { sbyte a1 = 11; SByte a2 = 11; Console.WriteLine(a1.GetType()); Console.WriteLine(a2.GetType()); short b1 = 11; Int16 b2 = 11; Console.WriteLine(b1.GetType()); Console.WriteLine(b2.GetType()); int c1 = 11; Int32 c2 = 11; Console.WriteLine(c1.GetType()); Console.WriteLine(c2.GetType()); long d1 = 11; Int64 d2 = 11; Console.WriteLine(d1.GetType()); Console.WriteLine(d2.GetType()); byte e1 = 11; Byte e2 = 11; Console.WriteLine(e1.GetType()); Console.WriteLine(e2.GetType()); ushort f1 = 11; UInt32 f2 = 11; Console.WriteLine(f1.GetType()); Console.WriteLine(f2.GetType()); char g1 = 'a'; Char g2 = 'a'; Console.WriteLine(g1.GetType()); Console.WriteLine(g2.GetType()); uint h1 = 11; UInt32 h2 = 11; Console.WriteLine(h1.GetType()); Console.WriteLine(h2.GetType()); ulong i1 = 11; UInt64 i2 = 11; Console.WriteLine(i1.GetType()); Console.WriteLine(i2.GetType()); float j1 = 11; Single j2 = 11; Console.WriteLine(j1.GetType()); Console.WriteLine(j2.GetType()); double k1 = 11; Double k2 = 11; Console.WriteLine(k1.GetType()); Console.WriteLine(k2.GetType()); decimal l1 = 11; Decimal l2 = 11; Console.WriteLine(l1.GetType()); Console.WriteLine(l2.GetType()); string m1 = "11"; String m2 = "11"; Console.WriteLine(m1.GetType()); Console.WriteLine(m2.GetType()); object n1 = 123456789; Object n2 = 1234.56789; Console.WriteLine(n1.GetType()); Console.WriteLine(n2.GetType()); Console.ReadKey(); }
static void Main(string[] args) { //числовые (целочисленные) byte bit1 = 1; Byte bit2 = 1; Console.WriteLine(bit1.GetType()); Console.WriteLine(bit2.GetType()); sbyte bit3 = 2; SByte bit4 = 2; Console.WriteLine(bit3.GetType()); Console.WriteLine(bit4.GetType()); short shot1 = 3; Int16 shot2 = 3; Console.WriteLine(shot1.GetType()); Console.WriteLine(shot2.GetType()); ushort shot3 = 4; UInt16 shot4 = 4; Console.WriteLine(shot3.GetType()); Console.WriteLine(shot4.GetType()); int i1 = 5; Int32 i2 = 5; Console.WriteLine(i1.GetType()); Console.WriteLine(i2.GetType()); uint i3 = 6; UInt32 i4 = 6; Console.WriteLine(i3.GetType()); Console.WriteLine(i4.GetType()); long l1 = 7; UInt64 l2 = 7; Console.WriteLine(l1.GetType()); Console.WriteLine(l2.GetType()); ulong l3 = 8; UInt64 l4 = 8; Console.WriteLine(l3.GetType()); Console.WriteLine(l4.GetType()); //числовые (c плавающей точкой) float flt1 = 9f; Single flt2 = 9f; Console.WriteLine(flt1.GetType()); Console.WriteLine(flt2.GetType()); double d1 = 10d; Double d2 = 10d; Console.WriteLine(d1.GetType()); Console.WriteLine(d2.GetType()); decimal dcm1 = 11m; Decimal dcm2 = 11m; Console.WriteLine(dcm1.GetType()); Console.WriteLine(dcm2.GetType()); //Символьные типы char chr1 = 'a'; Char chr2 = 'b'; Console.WriteLine(chr1.GetType()); Console.WriteLine(chr2.GetType()); string str1 = "word"; string str2 = "world"; Console.WriteLine(str1.GetType()); Console.WriteLine(str2.GetType()); //Логический тип bool bl1 = true; Boolean bl2 = false; Console.WriteLine(bl1.GetType()); Console.WriteLine(bl2.GetType()); //Особые типы object obj1 = i3; Object obj2 = str2; Console.WriteLine(obj1.GetType()); Console.WriteLine(obj2.GetType()); dynamic dnmc = "stringValue"; Console.WriteLine(dnmc.GetType()); Console.ReadKey(); }
public static Type ToType(CIMType cimtype, bool bIsArray, Property prop) { Type t = null; switch (cimtype) { case (CIMType.Boolean): { if (bIsArray) { Boolean[] ar = new Boolean[0]; t = ar.GetType(); } else { t = typeof(Boolean); } } break; case (CIMType.Char16): { if (bIsArray) { Char[] ar = new Char[0]; t = ar.GetType(); } else { t = typeof(Char); } } break; case (CIMType.DateTime): { if (WmiHelper.IsInterval(prop)) { if (bIsArray) { TimeSpan[] ar = new TimeSpan[0]; t = ar.GetType(); } else { t = typeof(TimeSpan); } } else { if (bIsArray) { DateTime[] ar = new DateTime[0]; t = ar.GetType(); } else { t = typeof(DateTime); } } } break; case (CIMType.Object): { if (bIsArray) { WMIObjectComponent[] ar = new WMIObjectComponent[0]; t = ar.GetType(); } else { t = typeof(WMIObjectComponent); } } break; case (CIMType.Real32): { if (bIsArray) { Single[] ar = new Single[0]; t = ar.GetType(); } else { t = typeof(Single); } } break; case (CIMType.Real64): { if (bIsArray) { Double[] ar = new Double[0]; t = ar.GetType(); } else { t = typeof(Double); } } break; case (CIMType.Reference): { if (bIsArray) { String[] ar = new String[0]; t = ar.GetType(); } else { t = typeof(String); } } break; case (CIMType.Sint16): { if (bIsArray) { Int16[] ar = new Int16[0]; t = ar.GetType(); } else { t = typeof(Int16); } } break; case (CIMType.Sint32): { if (bIsArray) { Int32[] ar = new Int32[0]; t = ar.GetType(); } else { t = typeof(Int32); } } break; case (CIMType.Sint64): { if (bIsArray) { Int64[] ar = new Int64[0]; t = ar.GetType(); } else { t = typeof(Int64); } } break; case (CIMType.Sint8): { if (bIsArray) { SByte[] ar = new SByte[0]; t = ar.GetType(); } else { t = typeof(SByte); } } break; case (CIMType.String): { if (bIsArray) { String[] ar = new String[0]; t = ar.GetType(); //return typeof(System.Collections.ArrayList); } else { t = typeof(String); } } break; case (CIMType.Uint16): { if (bIsArray) { UInt16[] ar = new UInt16[0]; t = ar.GetType(); } else { t = typeof(UInt16); } } break; case (CIMType.Uint32): { if (bIsArray) { UInt32[] ar = new UInt32[0]; t = ar.GetType(); } else { t = typeof(UInt32); } } break; case (CIMType.Uint64): { if (bIsArray) { UInt64[] ar = new UInt64[0]; t = ar.GetType(); } else { t = typeof(UInt64); } } break; case (CIMType.Uint8): { if (bIsArray) { Byte[] ar = new Byte[0]; t = ar.GetType(); } else { t = typeof(Byte); } } break; default: { if (bIsArray) { Object[] ar = new Object[0]; t = ar.GetType(); } else { t = typeof(Object); } } } return(t); }
public void TestIsPrimitiveMethod_UInt64() { UInt64 value = 1; TypeUtil.IsPrimitive(value.GetType()).IsTrue(); }
static void Main(string[] args) { sbyte a1 = -10; SByte a2 = -11; Console.WriteLine(a1.GetType()); Console.WriteLine(a2.GetType()); short b1 = -500; Int16 b2 = -400; Console.WriteLine(b1.GetType()); Console.WriteLine(b2.GetType()); int c1 = 123; Int32 c2 = -123; Console.WriteLine(c1.GetType()); Console.WriteLine(c2.GetType()); long d1 = -100000; Int64 d2 = 110000; Console.WriteLine(d1.GetType()); Console.WriteLine(d2.GetType()); byte e1 = 99; Byte e2 = 98; Console.WriteLine(e1.GetType()); Console.WriteLine(e2.GetType()); ushort f1 = 655; UInt16 f2 = 666; Console.WriteLine(f1.GetType()); Console.WriteLine(f2.GetType()); char g1 = 'c'; Char g2 = '!'; Console.WriteLine(g1.GetType()); Console.WriteLine(g2.GetType()); uint h1 = 333; UInt32 h2 = 334; Console.WriteLine(h1.GetType()); Console.WriteLine(h2.GetType()); ulong i1 = 12321; UInt64 i2 = 123321; Console.WriteLine(i1.GetType()); Console.WriteLine(i2.GetType()); float k1 = 2.2f; Single k2 = 45.05f; Console.WriteLine(k1.GetType()); Console.WriteLine(k2.GetType()); double l1 = 8.098; Double l2 = 8.98; Console.WriteLine(l1.GetType()); Console.WriteLine(l2.GetType()); decimal m1 = 1.2E3m; Decimal m2 = 1.3E2m; Console.WriteLine(m1.GetType()); Console.WriteLine(m2.GetType()); object obj1 = 9; Object obj2 = true; Console.WriteLine(obj1.GetType()); Console.WriteLine(obj2.GetType()); string str1 = "valar morghulis"; String str2 = "valar dohaeris"; Console.WriteLine(str1.GetType()); Console.WriteLine(str2.GetType()); }
public bool PosTest <T>(int id, T curValue, UInt64 expValue) { bool retVal = true; UInt64 newValue; IFormatProvider myfp; TestLibrary.TestFramework.BeginScenario("PosTest" + id + ": Convert.ToUInt64(...) (curValue:" + typeof(T) + " " + curValue + " newType:" + expValue.GetType() + ")"); try { newValue = Convert.ToUInt64(curValue); if (!newValue.Equals(expValue)) { TestLibrary.TestFramework.LogError("000", "Value mismatch: Expected(" + expValue + ") Actual(" + newValue + ")"); retVal = false; } myfp = null; newValue = Convert.ToUInt64(curValue, myfp); if (!newValue.Equals(expValue)) { TestLibrary.TestFramework.LogError("001", "Value mismatch: Expected(" + expValue + ") Actual(" + newValue + ")"); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e); retVal = false; } return(retVal); }