Link to home
Start Free TrialLog in
Avatar of ZURINET
ZURINET

asked on

Class Instantiation for multiple arrays

Hi all

Given the class below..
I need to create an instance of it and populate it with data.

I.e
Invoice varInvoice = new Invoice

varInvoice(FileType varXML, int varTransactionID, byte Data  )

given that byte is read from file..  and Given that I need to create and array type  Invoices[] varInvoices,
i.e Invoices[] will contain list of different invoices.. 1..n invoices..

Thanks in Advnace
public partial class Invoice {
        
        private string fileTypeField;
        
        private string transactionIDField;
        
        private byte[] dataField;
        
        /// <remarks/>
        public string FileType {
            get {
                return this.fileTypeField;
            }
            set {
                this.fileTypeField = value;
            }
        }
        
        /// <remarks/>
        public string TransactionID {
            get {
                return this.transactionIDField;
            }
            set {
                this.transactionIDField = value;
            }
        }
        
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")]
        public byte[] Data {
            get {
                return this.dataField;
            }
            set {
                this.dataField = value;
            }
        }
    }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Daniel Van Der Werken
Daniel Van Der Werken
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ZURINET
ZURINET

ASKER


Hi Dan7el
Given that I have a requirement to use array i.e Invoices []

How would that look like?

Thanks
Well, you'd have to know how many elements of the array you needed before hand, or have some mechanism for "dynamically" allocating new elements for each array.  That can be done of course, it's just a tad messy.

Given the same construcor:

int numElements = 60;
Invoice[] invoices = new Invoice[60];

for( int index = 0; index < numElements; index++ )
{
   // again, get the data and stuff.
   invoices[index] = new Invoice( fileType, transID, data );
}