玩转C科技.NET

从学会做人开始认识这个世界!http://volnet.github.io

导航

循环调用静态变量,你知道它的结果吗?

namespace CA_CycleInvokeStaticVariable
{
    using System;

    class A
    {
        public static int X;
        static A()
        {
            X = B.Y + 1;
        }
    }
    class B
    {
        public static int Y = A.X + 1;
        static B() { }
        static void Main(string[] args)
        {
            Console.WriteLine("X = {0}, Y = {1}", A.X, B.Y);
        }
    }
}
//X = 1, Y = 2

image

image

posted on 2009-02-25 21:05  volnet(可以叫我大V)  阅读(436)  评论(1编辑  收藏  举报

使用Live Messenger联系我
关闭