コード例 #1
0
    static void Main(string[] args)
    {
        KTest t = new KTest();

        t.Print();
        t.Print2();               // will not called in 'Release' configuration

        KTest2 t2 = new KTest2(); // generate compile-time warning

        bool isDefined = false;

        System.Type t3 = typeof(KTest3);
        MethodInfo  m  = t3.GetMethod("Method");

        isDefined = Attribute.IsDefined(t3, typeof(SampleAttribute));
        Console.WriteLine("isDefined = {0}", isDefined);

        isDefined = Attribute.IsDefined(m, typeof(SampleAttribute));
        Console.WriteLine("isDefined = {0}", isDefined);

        Console.ReadKey(true);

        /*  output in 'Debug' run.
         *  Print
         *  Print2
         *  isDefined = True
         *  isDefined = False
         */
    }
コード例 #2
0
    static void Main(string[] args)
    {
        KTest t = new KTest();

        t.Print();
        t.Print2();

        KTest2 t2 = new KTest2();

        //var assembly = Assembly.GetExecutingAssembly();
        //var types = assembly.GetTypes();
        //foreach( var type in types )
        //{
        //    Console.WriteLine( "Type: " + type.Name + ", Base Type: " + type.BaseType );
        //}
        Console.ReadKey(true);
    }