static void Main() { fmt.Printf("Type: {0} Value: {1}\n", GetGoTypeName(ToBe.GetType()), ToBe); fmt.Printf("Type: {0} Value: {1}\n", GetGoTypeName(MaxInt.GetType()), MaxInt); fmt.Printf("Type: {0} Value: ({1}+{2}i)\n", GetGoTypeName(z.GetType()), z.Real, z.Imaginary); }
static void Main(string[] args) { sbyte a1 = 1; System.SByte a2 = 1; byte b1 = 2; System.Byte b2 = 2; short c1 = 3; System.Int16 c2 = 3; ushort d1 = 4; System.UInt16 d2 = 4; int e1 = 5; System.Int32 e2 = 5; uint f1 = 6; System.UInt32 f2 = 6; long g1 = 7; System.Int64 g2 = 7; ulong h1 = 8; System.UInt64 h2 = 8; char i1 = 'a'; System.Char i2 = 'a'; float k1 = 10; System.Single k2 = 10; double l1 = 11; System.Double l2 = 11; bool m1 = true; System.Boolean m2 = true; decimal n1 = 12; System.Decimal n2 = 12; object o1 = new object { }; System.Object o2 = new object { }; string p1 = "Hello"; System.String p2 = "Hello"; Console.WriteLine(a1.GetType() + "\n" + a2.GetType() + "\n" + b1.GetType() + "\n" + b2.GetType() + "\n" + c1.GetType() + "\n" + c2.GetType() + "\n" + d1.GetType() + "\n" + d2.GetType() + "\n" + e1.GetType() + "\n" + e2.GetType() + "\n" + f1.GetType() + "\n" + f2.GetType() + "\n" + g1.GetType() + "\n" + g2.GetType() + "\n" + h1.GetType() + "\n" + h2.GetType() + "\n" + i1.GetType() + "\n" + i2.GetType() + "\n" + k1.GetType() + "\n" + k2.GetType() + "\n" + l1.GetType() + "\n" + l2.GetType() + "\n" + m1.GetType() + "\n" + m2.GetType() + "\n" + n1.GetType() + "\n" + n2.GetType() + "\n" + o1.GetType() + "\n" + o2.GetType() + "\n" + p1.GetType() + "\n" + p2.GetType() + "\n"); }
static void Main(string[] args) { // объявляю все переменные двумя способами sbyte a1 = 1; System.SByte a2 = 2; short b1 = 3; System.Int16 b2 = 4; int c1 = 5; System.Int32 c2 = 6; long d1 = 7; System.Int64 d2 = 8; byte e1 = 9; System.Byte e2 = 10; ushort f1 = 11; System.UInt16 f2 = 12; uint g1 = 13; System.UInt32 g2 = 14; ulong h1 = 15; System.UInt64 h2 = 16; char i1 = 'A'; System.Char i2 = 'B'; float j1 = 17.1F; System.Single j2 = 17.2F; double k1 = 17.11; System.Double k2 = 17.22; bool l1 = false; System.Boolean l2 = true; decimal m1 = 1.1M; System.Decimal m2 = 2.2M; object n1 = 18; System.Object n2 = 19; string o1 = "Hi!"; System.String o2 = "Bye!"; //получаю типы этих переменных Type nameA1 = a1.GetType(); Type nameA2 = a2.GetType(); Type nameB1 = b1.GetType(); Type nameB2 = b2.GetType(); Type nameC1 = c1.GetType(); Type nameC2 = c2.GetType(); Type nameD1 = d1.GetType(); Type nameD2 = d2.GetType(); Type nameE1 = e1.GetType(); Type nameE2 = e2.GetType(); Type nameF1 = f1.GetType(); Type nameF2 = f2.GetType(); Type nameG1 = g1.GetType(); Type nameG2 = g2.GetType(); Type nameH1 = h1.GetType(); Type nameH2 = h2.GetType(); Type nameI1 = i1.GetType(); Type nameI2 = i2.GetType(); Type nameJ1 = j1.GetType(); Type nameJ2 = j2.GetType(); Type nameK1 = k1.GetType(); Type nameK2 = k2.GetType(); Type nameL1 = l1.GetType(); Type nameL2 = l2.GetType(); Type nameM1 = m1.GetType(); Type nameM2 = m2.GetType(); Type nameN1 = n1.GetType(); Type nameN2 = n2.GetType(); Type nameO1 = o1.GetType(); Type nameO2 = o2.GetType(); //вывожу типы переменных на консоль Console.WriteLine(nameA1); Console.WriteLine(nameA2); Console.WriteLine(nameB1); Console.WriteLine(nameB2); Console.WriteLine(nameC1); Console.WriteLine(nameC2); Console.WriteLine(nameD1); Console.WriteLine(nameD2); Console.WriteLine(nameE1); Console.WriteLine(nameE2); Console.WriteLine(nameF1); Console.WriteLine(nameF2); Console.WriteLine(nameG1); Console.WriteLine(nameG2); Console.WriteLine(nameH1); Console.WriteLine(nameH2); Console.WriteLine(nameI1); Console.WriteLine(nameI2); Console.WriteLine(nameJ1); Console.WriteLine(nameJ2); Console.WriteLine(nameK1); Console.WriteLine(nameK2); Console.WriteLine(nameL1); Console.WriteLine(nameL2); Console.WriteLine(nameM1); Console.WriteLine(nameM2); Console.WriteLine(nameN1); Console.WriteLine(nameN2); Console.WriteLine(nameO1); Console.WriteLine(nameO2); }
static void Main(string[] args) { bool a = true; System.Boolean a1 = false; System.Type[] a2 = { a.GetType(), a1.GetType() }; foreach (var item in a2) { Console.Write(item.ToString() + "\n"); } byte b = 10; System.Byte b1 = 11; System.Type[] b2 = { b.GetType(), b1.GetType() }; foreach (var item in b2) { Console.Write(item.ToString() + "\n"); } sbyte c = 22; System.SByte c1 = 23; System.Type[] c2 = { c.GetType(), c1.GetType() }; foreach (var item in c2) { Console.Write(item.ToString() + "\n"); } short d = -33; System.Int16 d1 = -34; System.Type[] d2 = { d.GetType(), d1.GetType() }; foreach (var item in d2) { Console.Write(item.ToString() + "\n"); } ushort e = 33; System.UInt16 e1 = 34; System.Type[] e2 = { e.GetType(), e1.GetType() }; foreach (var item in e2) { Console.Write(item.ToString() + "\n"); } int f = 44; System.Int32 f1 = 45; System.Type[] f2 = { f.GetType(), f1.GetType() }; foreach (var item in f2) { Console.Write(item.ToString() + "\n"); } uint g = 55; System.UInt32 g1 = 56; System.Type[] g2 = { g.GetType(), g1.GetType() }; foreach (var item in g2) { Console.Write(item.ToString() + "\n"); } long h = -555; System.Int64 h1 = -556; System.Type[] h2 = { h.GetType(), h1.GetType() }; foreach (var item in h2) { Console.Write(item.ToString() + "\n"); } ulong i = 555; System.UInt64 i1 = 556; System.Type[] i2 = { i.GetType(), i1.GetType() }; foreach (var item in i2) { Console.Write(item.ToString() + "\n"); } float j = 666; System.Single j1 = 667; System.Type[] j2 = { j.GetType(), j1.GetType() }; foreach (var item in j2) { Console.Write(item.ToString() + "\n"); } double k = 777; System.Double k1 = 778; System.Type[] k2 = { k.GetType(), k1.GetType() }; foreach (var item in k2) { Console.Write(item.ToString() + "\n"); } decimal l = 888; System.Decimal l1 = 889; System.Type[] l2 = { l.GetType(), l1.GetType() }; foreach (var item in l2) { Console.Write(item.ToString() + "\n"); } char m = 'a'; System.Char m1 = 'b'; System.Type[] m2 = { m.GetType(), m1.GetType() }; foreach (var item in m2) { Console.Write(item.ToString() + "\n"); } string n = "Hello"; System.String n1 = "Bye"; System.Type[] n2 = { n.GetType(), n1.GetType() }; foreach (var item in n2) { Console.Write(item.ToString() + "\n"); } Console.ReadLine(); }
static void Main() { /* * prefix s - simple type, primitive type, built in type, value type * prefix f - .NET Framework type * * Numeric Types */ // signed 8 bit integer sbyte sByte = -128; System.SByte fByte = 127; // unsigned 8 bit integer byte sUnByte = 0; System.Byte fUnByte = 255; // signed 16 bit integer short sShort = -32768; System.Int16 fShort = 32767; // unsigned 16 bit integer ushort sUnShort = 0; System.UInt16 fUnShort = 65535; // signed 32 bit integer int sInt = -2147483648; System.Int32 fInt = 2_147_483_647; // unsigned 32 bit integer uint sUnInt = 0; System.UInt32 fUnInt = 4_294_967_295; // signed 64 bit integer long sLong = -9_223_372_036_854_775_808; System.Int64 fLong = 0x7FFFFFFFFFFFFFFF; // unsigned 64 bit integer ulong sUnLong = 0; System.UInt64 fUnLong = System.UInt64.MaxValue; // float 32 bit floating-point value (to initialize float use suffix 'f' or 'F') float sFloat = -3.5F; System.Single fFloat = 3.5f; // double 64 bit floating-point value double sDouble = System.Double.MinValue; System.Double fDouble = System.Double.MaxValue; // decimal 128 bit floating-point value (financial calculations)(use suffix m for real numbers) decimal sDecimal = 300.5m; System.Decimal fDecimal = 300; // character data type char sChar = 'a'; System.Char fChar = 'z'; // boolean type bool trueValue = true; bool falseValue = false; // default value for bool type // write to console Console.WriteLine("Type: {0}, Value: {1}", sByte.GetType(), sByte); Console.WriteLine("Type: {0}, Value: {1}", fByte.GetType(), fByte); Console.WriteLine("Type: {0}, Value: {1}", sUnByte.GetType(), sUnByte); Console.WriteLine("Type: {0}, Value: {1}", fUnByte.GetType(), fUnByte); Console.WriteLine("Type: {0}, Value: {1}", sShort.GetType(), sShort); Console.WriteLine("Type: {0}, Value: {1}", fShort.GetType(), fShort); Console.WriteLine("Type: {0}, Value: {1}", sUnShort.GetType(), sUnShort); Console.WriteLine("Type: {0}, Value: {1}", fUnShort.GetType(), fUnShort); Console.WriteLine("Type: {0}, Value: {1}", sInt.GetType(), sInt); Console.WriteLine("Type: {0}, Value: {1}", fInt.GetType(), fInt); Console.WriteLine("Type: {0}, Value: {1}", sUnInt.GetType(), sUnInt); Console.WriteLine("Type: {0}, Value: {1}", fUnInt.GetType(), fUnInt); Console.WriteLine("Type: {0}, Value: {1}", sLong.GetType(), sLong); Console.WriteLine("Type: {0}, Value: {1}", fLong.GetType(), fLong); Console.WriteLine("Type: {0}, Value: {1}", sUnLong.GetType(), sUnLong); Console.WriteLine("Type: {0}, Value: {1}", fUnLong.GetType(), fUnLong); Console.WriteLine("Type: {0}, Value: {1}", sFloat.GetType(), sFloat); Console.WriteLine("Type: {0}, Value: {1}", fFloat.GetType(), fFloat); Console.WriteLine("Type: {0}, Value: {1}", sDouble.GetType(), sDouble); Console.WriteLine("Type: {0}, Value: {1}", fDouble.GetType(), fDouble); Console.WriteLine("Type: {0}, Value: {1}", sDecimal.GetType(), sDecimal); Console.WriteLine("Type: {0}, Value: {1}", fDecimal.GetType(), fDecimal); Console.WriteLine("Type: {0}, Value: {1}", sChar.GetType(), sChar); Console.WriteLine("Type: {0}, Value: {1}", fChar.GetType(), fChar); Console.WriteLine("Type: {0}, Value: {1}", trueValue.GetType(), trueValue); Console.WriteLine("Type: {0}, Value: {1}", falseValue.GetType(), falseValue); // wait for user input to close the window Console.WriteLine(); Console.Write("Press any key to continue..."); Console.ReadKey(true); }