locked
needed - a memory queue- file - table RRS feed

  • Question

  • User483055775 posted

    The desktop environment I can from used a language called Clarion, and one of its features, very much like DEC Basic that I used through the later 70's and half the 80's had a feature called a memory queue.  This was a file ( or table , in new speak)  that was in memory and it acted just like a file. I use arrays a lot, but I dont know how many elements to allow for, which was the beauty of memory queues. What can I replace that functionality with - I use C# most of the time, VB when i can but anything C# has, so does vb.net so thanks in advance.

     

    DonnieS

    Tuesday, July 23, 2013 5:26 PM

Answers

  • User-821857111 posted

    You can use any type of generic collection. That way you get strong typing thrown in for free.

    public class Car
    {
        public string Model {get;set;}
        public int Year {get;set;} 
        public double Price {get;set;}
    }
    
    
    var cars = new List<Car>();
    cars.Add(new Car{Model = "Ford", Year = 1999, Price = 2000.00m});
    etc



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 24, 2013 2:29 AM

All replies

  • User-760709272 posted

    You can use a MemoryStream and a stream reader/writer to read/write the stream.  stream reader/writer abstracts what storage you are actually using so you can use them to write to any stream be it a file stream, memory stream, network stream etc.

    Tuesday, July 23, 2013 5:30 PM
  • User-821857111 posted

    You can use any type of generic collection. That way you get strong typing thrown in for free.

    public class Car
    {
        public string Model {get;set;}
        public int Year {get;set;} 
        public double Price {get;set;}
    }
    
    
    var cars = new List<Car>();
    cars.Add(new Car{Model = "Ford", Year = 1999, Price = 2000.00m});
    etc



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 24, 2013 2:29 AM
  • User483055775 posted

    What am I getting slapped around for here ?  The cars.Add line has red marks on the first (, then the {, then each = and the final )

     

     
     public class car
     {
         public string Model {get;set;}
         public int Year {get;set;}
         public double Price {get;set;}
     }   
     
     var cars = new List<car>();
       
      cars.Add(new car{Model = "Ford", Year = 1999, Price = 2000.00m});
     
        
    }
    Wednesday, July 24, 2013 5:09 PM
  • User483055775 posted

    The "public double Price {get;set;}"  need to be decimal not double.

     

    DonnieS

    Thursday, July 25, 2013 12:15 AM
  • User-821857111 posted

    No - the amount needed a D after it instead of a M :o)

    Thursday, July 25, 2013 12:38 AM
  • User483055775 posted

    Actually, a car would never be priced as a double, the 2000.00m  was correct, a car price should be a decimal. Smile   Thanks very much, the use of a collection in this class is going to be nice to use.

    Thursday, July 25, 2013 8:36 AM
  • User-1454326058 posted

    Hi Donnies,

    I'm glad to hear that your issue has been solved, please make the solution as answers which solved your issue.

    Thanks

    Best Regards

    Thursday, July 25, 2013 11:03 PM