コード例 #1
0
        public static int MainMethod()
        {
            dynamic x = new B();

            try
            {
                x.Foo <int>(); // Unexpected NullReferenceException
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e)
            {
                if (ErrorVerifier.Verify(ErrorMessageId.BadArity, e.Message, "B.Foo<T,S>()", ErrorVerifier.GetErrorElement(ErrorElementId.SK_METHOD), "2"))
                {
                    B.Status = 0;
                }
            }

            return(B.Status);
        }
コード例 #2
0
        public static int MainMethod(string[] args)
        {
            dynamic d      = new C();
            int     result = 0;
            int     error  = 0;

            try
            {
                result = d.Foo <int>();
                System.Console.WriteLine("Should have thrown out runtime exception!");
                error++;
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex)
            {
                if (!ErrorVerifier.Verify(ErrorMessageId.HasNoTypeVars, ex.Message, "C.Foo()", ErrorVerifier.GetErrorElement(ErrorElementId.SK_METHOD)))
                {
                    error++;
                }
            }

            return(error);
        }