Thread: collection

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    141

    collection

    I want to build a data structure having a collection of array of streams. How can I make that?

  2. #2
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,110
    Isnt that the same as what you asked here: http://cboard.cprogramming.com/showthread.php?t=80251 ?

    Anyway you could create a class, that has a private array of Streams. Then use the indexer of that class to get to the Streams itself from outside the class.

    something like:

    Code:
    using System;
    using System.Text;
    using System.IO;
    
    namespace GUITestC {
    	public class MyStreams {
    
    		private FileStream[] myStreams;
    
    		public MyStreams(int totalAmountOfStreams) {
    			this.myStreams = new FileStream[totalAmountOfStreams];
    		}
    
    		public FileStream this[int index]{
    			get {
    				return this.myStreams[index];
    			}
    			set {
    				this.myStreams[index] = value;
    			}
    		}
    	}
    }
    Of course the indexer would need to do some checking on boundaries of arrays, and look at the type of objects being assigned to the array .

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ Garbage Collection
    By vaibhav in forum C++ Programming
    Replies: 1
    Last Post: 11-27-2005, 10:26 AM
  2. Garbage Collection
    By Orborde in forum C++ Programming
    Replies: 4
    Last Post: 05-10-2005, 11:18 PM
  3. username collection
    By algi in forum C++ Programming
    Replies: 3
    Last Post: 01-22-2005, 02:20 PM
  4. garbage collection
    By joed in forum C Programming
    Replies: 4
    Last Post: 04-01-2004, 01:47 PM