方法的递归

1.方法的递归

自己调用自己

static void Main(string[] args)
        {
            //Console.WriteLine("Hello World!");
            Program pr = new Program();
            pr.Count(3);
        }


        public void Count(int intVal)
        {
            if (intVal == 0)
            {
                return;
            }
            Count(intVal - 1);//自己调用自己
            Console.WriteLine("{0}", intVal);
        }

 

posted @ 2022-02-21 15:53  makaay986  阅读(27)  评论(0)    收藏  举报