[C#]Real time example of recursion > C#/.Net/Blazor/IIS

본문 바로가기
사이트 내 전체검색

C#/.Net/Blazor/IIS

[C#]Real time example of recursion

페이지 정보

작성자 sbLAB 댓글 0건 조회 4,385회 작성일 18-07-25 17:35

본문


※ recursion 를 이해할때는 단일의 자신 펑션을 바라보면서 파라미터값이 다시 들어간다는 생각하면

 복잡하다.

   

recursion 펑션을 만날때, 똑 같은 

 
FindFiles 함수가 별도로 메모리에 추가 생성 된다고 이해하자.



using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace recursion
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("please enter path");
            string path = Console.ReadLine();
            FindFiles(path);
 
            Console.ReadKey();
        }
 
 
        //example of recursion
        private static void FindFiles(string path)
        {
            foreach (string fileName in Directory.GetFiles(path))
            {
                Console.WriteLine(fileName);
            }
 
            foreach (string directory in Directory.GetDirectories(path))
            {
                FindFiles(directory);
            }
        }
 
    }
}

댓글목록

등록된 댓글이 없습니다.

회원로그인

접속자집계

오늘
489
어제
396
최대
1,279
전체
222,539

그누보드5
Copyright © sebom.com All rights reserved.