首页 > 编程语言 >C# this 关键字

C# this 关键字

时间:2022-11-07 20:12:53浏览次数:50  
标签:C# void class 关键字 num new public

class A
    {
        public int num = 3;
        public void m1(B b)
        {
            b.m2(this);
        }
    }
    class B
    {       
        public void m2(A a)
        {
            Console.WriteLine(a.num);
        }
    }
    
    class Test
    {
        public static void Main(string[] args)
        {
            A a = new A();
            B b = new B();
            a.m1(b);      //3
        }
    }  

 

标签:C#,void,class,关键字,num,new,public
From: https://www.cnblogs.com/sound-of-wind-rain/p/16867253.html

相关文章