Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. iteration

iteration

Scheduled Pinned Locked Moved C#
csharpvisual-studioc++data-structureshelp
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    adrian564
    wrote on last edited by
    #1

    Hello all, I would appreciate any help that can be given. I'm new to c# and mostly develop in c++. I'm using Microsoft Visual Studio 2010 as my IDE. My question is I'd like to ouput cars from a car collection. I'm using a 3rd party DLL library. As far as I know the dll has 2 classes. They are CarCollection and Car. CarCollection has the following functions:

    using System;
    using System.Collections.Generic;

    namespace CaraPartnersSdk
    {
    public class CarCollection
    {
    public CarCollection();

        public IEnumerable<Car> FindByName(string name);
        public Car GetByID(int id);
    }
    

    }

    Car.cs:

    using System;
    using System.Collections.Generic;

    namespace CaraPartnersSdk
    {
    public class Car
    {
    public Car();

        public string AlternateForm { get; }
        public Condition Condition { get; }
        public IEnumerable<Car> ConnectsToCars { get; }
        public bool HasBeenOpened { get; }
        public int ID { get; }
        public string Name { get; }
        public string OptionalAttributesXml { get; }
        public decimal Price { get; }
        public string Set { get; }
        public int Strength { get; }
    }
    

    }

    All I'm trying to do is output each Car's name and ID which is in the dll. For now, I'm using a simple main class. I have no idea how to iterate through the CarCollection since it's not an array or actual collection. I'm doing CarCollection aCollection = new CarCollection(); When I use aCollection.FindByName() I get a message which does not help. After that I'm stumped. I know I have to use public IEnumerable<Car> FindByName(string name); from the CarCollection class but I have no idea how. I wish they passed the collection as an array because then I can do a simple for loop like for(int i = 0; i

    A P 2 Replies Last reply
    0
    • A adrian564

      Hello all, I would appreciate any help that can be given. I'm new to c# and mostly develop in c++. I'm using Microsoft Visual Studio 2010 as my IDE. My question is I'd like to ouput cars from a car collection. I'm using a 3rd party DLL library. As far as I know the dll has 2 classes. They are CarCollection and Car. CarCollection has the following functions:

      using System;
      using System.Collections.Generic;

      namespace CaraPartnersSdk
      {
      public class CarCollection
      {
      public CarCollection();

          public IEnumerable<Car> FindByName(string name);
          public Car GetByID(int id);
      }
      

      }

      Car.cs:

      using System;
      using System.Collections.Generic;

      namespace CaraPartnersSdk
      {
      public class Car
      {
      public Car();

          public string AlternateForm { get; }
          public Condition Condition { get; }
          public IEnumerable<Car> ConnectsToCars { get; }
          public bool HasBeenOpened { get; }
          public int ID { get; }
          public string Name { get; }
          public string OptionalAttributesXml { get; }
          public decimal Price { get; }
          public string Set { get; }
          public int Strength { get; }
      }
      

      }

      All I'm trying to do is output each Car's name and ID which is in the dll. For now, I'm using a simple main class. I have no idea how to iterate through the CarCollection since it's not an array or actual collection. I'm doing CarCollection aCollection = new CarCollection(); When I use aCollection.FindByName() I get a message which does not help. After that I'm stumped. I know I have to use public IEnumerable<Car> FindByName(string name); from the CarCollection class but I have no idea how. I wish they passed the collection as an array because then I can do a simple for loop like for(int i = 0; i

      A Offline
      A Offline
      Abhinav S
      wrote on last edited by
      #2

      adrian564 wrote:

      I get a message which does not help

      Can you post the message here?

      Me, I'm dishonest. And a dishonest man you can always trust to be dishonest.
      Honestly. It's the honest ones you want to watch out for...

      A 1 Reply Last reply
      0
      • A Abhinav S

        adrian564 wrote:

        I get a message which does not help

        Can you post the message here?

        Me, I'm dishonest. And a dishonest man you can always trust to be dishonest.
        Honestly. It's the honest ones you want to watch out for...

        A Offline
        A Offline
        adrian564
        wrote on last edited by
        #3

        Hello all, I would appreciate any help that can be given. I'm new to c# and mostly develop in c++. I'm using Microsoft Visual Studio 2010 as my IDE. My question is I'd like to ouput cars from a car collection. I'm using a 3rd party DLL library. As far as I know the dll has 2 classes. They are CarCollection and Car. CarCollection has the following functions: using System; using System.Collections.Generic; namespace CaraPartnersSdk { public class CarCollection { public CarCollection(); public IEnumerable<Car> FindByName(string name); public Car GetByID(int id); } } Car.cs: using System; using System.Collections.Generic; namespace CaraPartnersSdk { public class Car { public Car(); public string AlternateForm { get; } public Condition Condition { get; } public IEnumerable<Car> ConnectsToCars { get; } public bool HasBeenOpened { get; } public int ID { get; } public string Name { get; } public string OptionalAttributesXml { get; } public decimal Price { get; } public string Set { get; } public int Strength { get; } } } All I'm trying to do is output each Car's name and ID which is in the dll. For now, I'm using a simple main class. I have no idea how to iterate through the CarCollection since it's not an array or actual collection. I'm doing CarCollection aCollection = new CarCollection(); When I use aCollection.FindByName() I get a message which does not help. After that I'm stumped. I know I have to use public IEnumerable<Car> FindByName(string name); from the CarCollection class but I have no idea how. I wish they passed the collection as an array because then I can do a simple for loop like for(int i = 0; i { collection(i).getName(); } something like that, but I guess thats not the case. Please I would appreciate any help. Thanks. -Adrian

        V 1 Reply Last reply
        0
        • A adrian564

          Hello all, I would appreciate any help that can be given. I'm new to c# and mostly develop in c++. I'm using Microsoft Visual Studio 2010 as my IDE. My question is I'd like to ouput cars from a car collection. I'm using a 3rd party DLL library. As far as I know the dll has 2 classes. They are CarCollection and Car. CarCollection has the following functions: using System; using System.Collections.Generic; namespace CaraPartnersSdk { public class CarCollection { public CarCollection(); public IEnumerable<Car> FindByName(string name); public Car GetByID(int id); } } Car.cs: using System; using System.Collections.Generic; namespace CaraPartnersSdk { public class Car { public Car(); public string AlternateForm { get; } public Condition Condition { get; } public IEnumerable<Car> ConnectsToCars { get; } public bool HasBeenOpened { get; } public int ID { get; } public string Name { get; } public string OptionalAttributesXml { get; } public decimal Price { get; } public string Set { get; } public int Strength { get; } } } All I'm trying to do is output each Car's name and ID which is in the dll. For now, I'm using a simple main class. I have no idea how to iterate through the CarCollection since it's not an array or actual collection. I'm doing CarCollection aCollection = new CarCollection(); When I use aCollection.FindByName() I get a message which does not help. After that I'm stumped. I know I have to use public IEnumerable<Car> FindByName(string name); from the CarCollection class but I have no idea how. I wish they passed the collection as an array because then I can do a simple for loop like for(int i = 0; i { collection(i).getName(); } something like that, but I guess thats not the case. Please I would appreciate any help. Thanks. -Adrian

          V Offline
          V Offline
          VCsamir
          wrote on last edited by
          #4

          hi, this might be one of the way to solve it. you can use LINQ query to do it in a neat way IEnumerable carnames = from cars in car select cars.name; foreach(string cr in carnames) { //do whatever with cr } i feel linq is really a nice concept introduced.. infact i have become a fan of it. in above u can specify the 'where' condition also as per your need.. Hope this helps u... Regards Samir

          A 2 Replies Last reply
          0
          • V VCsamir

            hi, this might be one of the way to solve it. you can use LINQ query to do it in a neat way IEnumerable carnames = from cars in car select cars.name; foreach(string cr in carnames) { //do whatever with cr } i feel linq is really a nice concept introduced.. infact i have become a fan of it. in above u can specify the 'where' condition also as per your need.. Hope this helps u... Regards Samir

            A Offline
            A Offline
            adrian564
            wrote on last edited by
            #5

            Hello, I'm still really confused, so I tried this

            IEnumerable<string> carnames = from cars in Car
            select cars.name;

            The error I get is error CS1936: Could not find an implementation of the query pattern for source type 'CaraPartnersSdk.Robot'. 'Select' not found. I'm real confused I just want to print out the string name of the car. Please help. Best, Adrian

            1 Reply Last reply
            0
            • V VCsamir

              hi, this might be one of the way to solve it. you can use LINQ query to do it in a neat way IEnumerable carnames = from cars in car select cars.name; foreach(string cr in carnames) { //do whatever with cr } i feel linq is really a nice concept introduced.. infact i have become a fan of it. in above u can specify the 'where' condition also as per your need.. Hope this helps u... Regards Samir

              A Offline
              A Offline
              adrian564
              wrote on last edited by
              #6

              Hello, I'm still really confused, so I tried this <pre> IEnumerable<string> carnames = from cars in Car select cars.name; </pre> The error I get is error CS1936: Could not find an implementation of the query pattern for source type 'CaraPartnersSdk.Robot'. 'Select' not found. I'm real confused I just want to print out the string name of the car. Please help. Best, Adrian

              A 1 Reply Last reply
              0
              • A adrian564

                Hello, I'm still really confused, so I tried this <pre> IEnumerable<string> carnames = from cars in Car select cars.name; </pre> The error I get is error CS1936: Could not find an implementation of the query pattern for source type 'CaraPartnersSdk.Robot'. 'Select' not found. I'm real confused I just want to print out the string name of the car. Please help. Best, Adrian

                A Offline
                A Offline
                adrian564
                wrote on last edited by
                #7

                Anyone? any suggestions? Maybe a helpful book or website? Thanks.

                1 Reply Last reply
                0
                • A adrian564

                  Hello all, I would appreciate any help that can be given. I'm new to c# and mostly develop in c++. I'm using Microsoft Visual Studio 2010 as my IDE. My question is I'd like to ouput cars from a car collection. I'm using a 3rd party DLL library. As far as I know the dll has 2 classes. They are CarCollection and Car. CarCollection has the following functions:

                  using System;
                  using System.Collections.Generic;

                  namespace CaraPartnersSdk
                  {
                  public class CarCollection
                  {
                  public CarCollection();

                      public IEnumerable<Car> FindByName(string name);
                      public Car GetByID(int id);
                  }
                  

                  }

                  Car.cs:

                  using System;
                  using System.Collections.Generic;

                  namespace CaraPartnersSdk
                  {
                  public class Car
                  {
                  public Car();

                      public string AlternateForm { get; }
                      public Condition Condition { get; }
                      public IEnumerable<Car> ConnectsToCars { get; }
                      public bool HasBeenOpened { get; }
                      public int ID { get; }
                      public string Name { get; }
                      public string OptionalAttributesXml { get; }
                      public decimal Price { get; }
                      public string Set { get; }
                      public int Strength { get; }
                  }
                  

                  }

                  All I'm trying to do is output each Car's name and ID which is in the dll. For now, I'm using a simple main class. I have no idea how to iterate through the CarCollection since it's not an array or actual collection. I'm doing CarCollection aCollection = new CarCollection(); When I use aCollection.FindByName() I get a message which does not help. After that I'm stumped. I know I have to use public IEnumerable<Car> FindByName(string name); from the CarCollection class but I have no idea how. I wish they passed the collection as an array because then I can do a simple for loop like for(int i = 0; i

                  P Offline
                  P Offline
                  PIEBALDconsult
                  wrote on last edited by
                  #8

                  To enumerate an enumerator, all you need is a foreach statement. I'm also assuming that FindByName can take a wildcard. But, as you still haven't told us what error you were getting, we still don't know!

                  modified on Wednesday, April 7, 2010 11:29 PM

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups