using System; using System.Reflection; class LiteralTest { private enum Color { red = 0, green = 1, blue = 2, yellow = 3, } private const bool bool_value = false; private const sbyte byte_value = sbyte.MaxValue; private const byte ubyte_value = 223; private const short short_value = 456; private const ushort ushort_value = 65525; private const char char_value = 'A'; private const int int_value = 2147483637; private const uint uint_value = 4294967285; private const long long_value = 9223372036854775797; private const ulong ulong_value = 0xfffffffffffffff5; private const float f = 4.28657869E9F; private const float float_value = float.MaxValue; private const double double_value = double.MaxValue; public static void Main() { enumLiteral(Color.green); Console.WriteLine(typeof(Color)); Console.WriteLine(4.28657869E9F); Console.WriteLine(float.NegativeInfinity); Console.WriteLine(double.NaN); Console.WriteLine(float.MinValue); float f = 0.0F; double d1 = 0.1; double d2 = 0.0; Console.WriteLine(uint.MaxValue); Console.WriteLine((long)-1); byte b = 155; Console.WriteLine(b); b = 100; Console.WriteLine(b); ushort s = 65435; Console.WriteLine((int)s); s = 100; Console.WriteLine((int)s); Console.WriteLine(4294967195); switchLiteral_1("Public"); } private void invokeProperty() { AppDomain appDomain = AppDomain.CurrentDomain; } private void enumLiteral() { Console.WriteLine(1); } private static void enumLiteral(Color c) { Console.WriteLine(c); MethodAttributes methodAttributes1 = MethodAttributes.Public; MethodAttributes methodAttributes2 = 22; } private void switchLiteral(MethodAttributes ta) { MethodAttributes methodAttributes = ta; if (methodAttributes <= MethodAttributes.Public) { if (methodAttributes == MethodAttributes.Private) { Console.WriteLine("private"); } else if (methodAttributes == MethodAttributes.Public) { Console.WriteLine("public"); } } else if (methodAttributes == MethodAttributes.Static) { Console.WriteLine("static"); } else if (methodAttributes == MethodAttributes.Virtual) { Console.WriteLine("virtual"); } } private static void switchLiteral_1(string s) { string str; if ((str = s) != null) { str = String.IsInterned(str); if (str == "Public") { Console.WriteLine("public"); } else if (str == "Static") { Console.WriteLine("static"); } else if (str == "Private") { Console.WriteLine("private"); } } } private void nullLiteral() { int i = 0; i++; if (i != 0) { Console.WriteLine("i != 0"); } string str = null; if ("John" != null) { Console.WriteLine("s != null"); } char[] chs = new char[10]; if (chs[0] != '\0') { i++; } object local = null; bool flag = local is String; } }