Given the below code I want to be able to find an element in the myProjectsDicList
using a key (string) in a different dictionary. But look for it in projectsArrayList
array. Specifically the htmleditor.ProjectName
string is what I want to find. There is only 1 List<ArrayList>
in the dictionary. This array list contains the projects array list.
I tried this below but doesn't work....
string key = "Project Name";
var match = myProjectsDicList.Where(item => item.Value[0].Cast<object>().Where(x => x.ProjectName == key).Select(x => x.ProjectName).First());
I'm trying to find a way to replace this code to find the HTMLEditor that works with a select statement.
bool foundHTMLEditor = false;
for (int i = 0; i < myProjectsDicList.Count; i++)
{
List<ArrayList> allprojects = myProjectsDicList.ElementAt(i).Value;
for (int j = 0; j < allprojects[0].Count; j++)
{
HTMLEditor e = (HTMLEditor)allprojects[0][j];
if (e.ProjectName == key)
{
foundHTMLEditor = true;
break;
}
}
if(foundHTMLEditor == true)
{
break;
}
}
Here is the code I have...
public class MultiDimDictList : Dictionary<string, List<ArrayList>>
{
}
projects = new ArrayList();
List<ArrayList> projectsArrayList = new List<ArrayList>();
// create the dictionary
MultiDimDictList myProjectsDicList = new MultiDimDictList();
// create an htmleditor instance and set one of the variables
HTMLEditor htmleditor = new HTMLEditor();
htmleditor.ProjectName = "Project Name";
// add the htmleditor to the projects array list
projects.Add(htmleditor);
// add the projects array list to the List
projectsArrayList.Add(projects);
// add the projects array list to the dictionary list
myProjectsDicList.Add(domainName, projectsArrayList);