Cannot apply indexing with [] to an expression of type 'System.Collections.Generic.IEnumerable<ANY_TYPE>
Solution:
If used of IEnumerable
- SampleArray[index] WRONG
- SampleArray.ElementAt(index) RIGHT
Because the IEnumerable
Amastaneh blog is a discussion site on software development, programming, algorithms, software architectures,software run-time errors and solutions from software engineers who love building great softwares.
BindingListCollectionView CurrentView = categoriesViewSource.View as BindingListCollectionView; Table tb1 = CurrentView.AddNew() as Table1; tb1.ID = Guid.NewGuid(); this.CurrentView.CommitNew();
TreeViewItem matchItam = SelectTreeViewItem(this.treeView1.Items, "sample value");
private TreeViewItem SelectTreeViewItem(ItemCollection Collection, String Value) { if (Collection == null) return null; foreach(TreeViewItem Item in Collection) { /// Find in current if (Item.Header.Equals(Value)) { Item.IsSelected = true; return Item; } /// Find in Childs if (Item.Items != null) { TreeViewItem childItem = this.SelectTreeViewItem(Item.Items, Value); if (childItem != null) { Item.IsExpanded = true; return childItem; } } } return null; }