Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have a list of views elements which I've obtained by using a FilteredElementCollector.
I now need to iterate through the list and select the one which matches the name I want.
The problem is that I can't take the view I want outside the For loop due to its scope.
Ordinarily, I would define the variable outside the loop, but I can't do this with the View class as it doesn't contain a constructor...
This is my code:
View selectedview = new View(); foreach (View f in allviewlist) { if (f.Name == "East") { selectedview = f; } }
The first line fails.
Whats the best way of accessing the 'selectedview'?
Thanks.
Solved! Go to Solution.