Click here to Skip to main content
15,890,932 members
Home / Discussions / C#
   

C#

 
AnswerRe: Serialization Problem Pin
William Winner24-May-10 13:07
William Winner24-May-10 13:07 
GeneralRe: Serialization Problem Pin
Kevin Marois24-May-10 13:08
professionalKevin Marois24-May-10 13:08 
GeneralRe: Serialization Problem Pin
William Winner24-May-10 13:10
William Winner24-May-10 13:10 
GeneralRe: Serialization Problem Pin
Kevin Marois24-May-10 13:13
professionalKevin Marois24-May-10 13:13 
GeneralRe: Serialization Problem Pin
Ravi Bhavnani24-May-10 14:35
professionalRavi Bhavnani24-May-10 14:35 
QuestionFtpWebRequest accepting a port number when UsePassive = true. Does this violate RFC 959? Pin
Alaric_24-May-10 8:47
professionalAlaric_24-May-10 8:47 
QuestionIterator, foreach, IEnumerable IEnumerator for a beginner :s Pin
bon_chan24-May-10 7:47
bon_chan24-May-10 7:47 
AnswerRe: Iterator, foreach, IEnumerable IEnumerator for a beginner :s Pin
Luc Pattyn24-May-10 8:04
sitebuilderLuc Pattyn24-May-10 8:04 
bon_chan wrote:
Is it correct?


No, all of that is wrong. I'll try to keep it simple, which may make it slightly incorrect. Here you go:

Enumerator, iterator and enumerable are pretty much the same. They offer an abstracted way to enumerate items in a collection, which means getting access to them, one after the other, in sequence.

foreach(someType varName in someCollection) does not implement IEnumerator nor IEnumerable; it requires someCollection to implement IEnumerable, as it will use an enumerator on someCollection and loop its way through it; you could do that yourself, based on a for loop and an explicit call to someCollection.GetEnumerator().

yield is a keyword that got introduced later; it helps in enumerating virtual collections, i.e. collections that do not really exist as a set of elements all available concurrently. You should not worry about it at all, until you fully understand everything else about enumerators.

Summary: it is all about enumerating; you don't really need it; it can come in handy; it can be virtualized. Take it one step at a time.

PS: Wrox books have good reputation; you should study some more. And experiment a bit too.

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read formatted code with indentation, so please use PRE tags for code snippets.

I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).

AnswerRe: Iterator, foreach, IEnumerable IEnumerator for a beginner :s Pin
Abhinav S24-May-10 18:23
Abhinav S24-May-10 18:23 
GeneralRe: Iterator, foreach, IEnumerable IEnumerator for a beginner :s Pin
bon_chan25-May-10 4:48
bon_chan25-May-10 4:48 
Question2D Map collison help required Pin
venomation24-May-10 7:00
venomation24-May-10 7:00 
AnswerRe: 2D Map collison help required [modified] Pin
Alaric_24-May-10 8:55
professionalAlaric_24-May-10 8:55 
AnswerRe: 2D Map collison help required Pin
Alaric_24-May-10 9:07
professionalAlaric_24-May-10 9:07 
GeneralRe: 2D Map collison help required [modified] Pin
Alaric_25-May-10 4:48
professionalAlaric_25-May-10 4:48 
AnswerRe: 2D Map collison help required Pin
venomation26-May-10 5:59
venomation26-May-10 5:59 
QuestionMessage Removed Pin
24-May-10 3:30
Xpnctoc24-May-10 3:30 
AnswerRe: Form controls data binding sequence Pin
Luc Pattyn24-May-10 5:21
sitebuilderLuc Pattyn24-May-10 5:21 
GeneralRe: Form controls data binding sequence Pin
Xpnctoc24-May-10 5:30
Xpnctoc24-May-10 5:30 
GeneralRe: Form controls data binding sequence Pin
Luc Pattyn24-May-10 7:50
sitebuilderLuc Pattyn24-May-10 7:50 
GeneralRe: Form controls data binding sequence Pin
Xpnctoc24-May-10 8:00
Xpnctoc24-May-10 8:00 
GeneralRe: Form controls data binding sequence Pin
Luc Pattyn24-May-10 8:09
sitebuilderLuc Pattyn24-May-10 8:09 
GeneralRe: Form controls data binding sequence Pin
Xpnctoc24-May-10 8:15
Xpnctoc24-May-10 8:15 
QuestionVisual Studions 2005 and crystal reports 11.5 R2 Pin
krown24-May-10 2:56
krown24-May-10 2:56 
QuestionWhy am I recieving corrupt images? Pin
TimSWatson24-May-10 2:37
TimSWatson24-May-10 2:37 
AnswerRe: Why am I recieving corrupt images? Pin
Luc Pattyn24-May-10 4:53
sitebuilderLuc Pattyn24-May-10 4:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.