Search Results

Search found 1 results on 1 pages for 'mostaguen'.

Page 1/1 | 1 

  • displaying structs in an array using enumerator

    - by Mostaguen
    In an object I have : public IEnumerable<voiture> recup_voitures() { foreach (voiture v in _arrVCollection) { yield return (v); } } voiture being a struct and _arrVCollection being an array containing some struct voiture. In my main class I have : foreach (CarCollection.voiture o in collection.recup_voitures()) { //some code to display the content of each struct } What is happening is that if I have an array of length 5 and only 1 struct voiture in it, it will do the displaying code 5 times instead of only 1. What am I doing wrong?

    Read the article

1