collection

This is a discussion on collection within the C# Programming forums, part of the General Programming Boards category; I want to build a data structure having a collection of array of streams. How can I make that?...

  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,109
    Isnt that the same as what you asked here: A couple of stream questions ?

    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-11-2005, 12:18 AM
  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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21