John

John

  • NA
  • 928
  • 126.3k

Recursive function in foreach

Jun 1 2017 12:41 AM
I have to call a function recursively using foreach something like this
 
public JsonResult GetPath(string node)
{
try
{
var project_id = "abc";
String fName = "";
String fID = "";
foreach (string items in GetFolders(project_id, node))
{
for (int j = 0; j < items.Length; j++)
{
if (items.Length == 100000)
{
break;
}
else
{
var Totalitems = items.Split('~');
folderID = Totalitems[0].ToString();
FolderName += Totalitems[1].ToString()+",";
}
}
GetPath(items);
}
}
catch(Exception)
{
}
return Json("", JsonRequestBehavior.AllowGet);
}
 
In this method this GetFolders will return and array
 
Problem is i cant declare string array in foreach 
 

Answers (3)