Use of recursion in C#.
The function that calls itself is called as recursion.
Real time example:- When and where do we use the recursion in our projects?
A simple answer to this question is, "To find all the files in a folder, and in all the sub folders in the hierarchy."
Given below is a good example of the recursion.
private static void Findfiles(string path)
{
foreach( string filename in directory.getFile(path))
{
console.writeline(Filename);
}
foreach( string filename in directory.getDirectories(path))
{
//find file calling itself
findFile(directory);
}
}