Created
February 7, 2012 17:48
-
-
Save AlphaGit/1760972 to your computer and use it in GitHub Desktop.
StackOverflow on GetEnumerator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TableCountryMappingCollection : ConfigurationElementCollection, IList<TableCountryMapping> | |
{ | |
//... | |
IEnumerator<TableCountryMapping> IEnumerable<TableCountryMapping>.GetEnumerator() | |
{ | |
foreach (var item in ((System.Collections.IEnumerable)this).Cast<TableCountryMapping>()) | |
yield return item; | |
} | |
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() | |
{ | |
return base.GetEnumerator(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Con
this.Select(x => x)
o con((System.Collections.IEnumerable)this).Cast<TableCountryMapping>()
también estabas accediendo alGetEnumerator()
deTableCountryMappingCollection
ya que Linq accede alGetEnumerator()
por reflection y no por polimorfismo como si hace elforeach
.