OUT的用法

    static void Main(string[] args)
        {
            int test = 100;
            int s;//申明变明来接收方法返回的值

            Console.WriteLine(M1(test,out s));
            Console.WriteLine(s);


        }
        //当想一个方法同时要返回多个值折时候,可以考虑命使用OUT
        static bool M1( int n,out int s)
        {
            s = n - 5;//out参数,在方法中必须赋值
            if (n>5)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

 

posted @ 2014-12-28 22:07  kevin.dai  阅读(312)  评论(0编辑  收藏  举报