locked
IEnumerable Question RRS feed

  • Question

  • public static BoundingBox CreateFromPoints (
         IEnumerable<Vector3> points
    )
    I would like to be able to utilize this method above. However, I not to sure how to delcare an IEnumeral of Vector3. I think I understand the
    concept. It is a list of 3D vectors that the method takes. But How can I delcare the list of Vector3 objects into a IEnumeral.
    If someone could post a code example of how you would pass a parameter into this function, along with an explaination of how the 
    parameters where declared. THank you.
    Thursday, June 30, 2011 12:47 PM

Answers

  • List<Vector3> myVects = ... valid creation of list with objects.

     

    return myVects.AsEnumerable();

     

     

    HTH


    William Wegerson (www.OmegaCoder.Com)
    • Proposed as answer by Cookie Luo Tuesday, July 5, 2011 6:02 AM
    • Marked as answer by Cookie Luo Sunday, July 10, 2011 1:02 PM
    Thursday, June 30, 2011 1:15 PM
    Moderator

All replies

  • Hi Bud,

    IEnumerable is an interface so any class that implements that interface can be passed in. Class types that implement IEnumerable are things like a List, List<Vector3>, or an array, Vector3[] ... those are the types of classes that can be used.

     

     

    Hope that helps.


    "The programmer, like the poet, works only slightly removed from pure thought-stuff. He builds his castles in the air, from air, creating by exertion of the imagination." - Fred Brooks
    Thursday, June 30, 2011 1:01 PM
  • List<Vector3> myVects = ... valid creation of list with objects.

     

    return myVects.AsEnumerable();

     

     

    HTH


    William Wegerson (www.OmegaCoder.Com)
    • Proposed as answer by Cookie Luo Tuesday, July 5, 2011 6:02 AM
    • Marked as answer by Cookie Luo Sunday, July 10, 2011 1:02 PM
    Thursday, June 30, 2011 1:15 PM
    Moderator