Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Redimensioning an array in c#
Message
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows 10
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01627021
Message ID:
01627183
Views:
57
Makes sense! I would not even need the invoice class, I can split after I retrieve.... Thank you so much.

Need to get used to the idea of "explicit operator" also. Looks hot! :)

>Depending on what you need you could use a class for invoice. e.g.
public class Invoice
>    {
>        public static explicit operator Invoice(string fields)
>        {
>            string[] array = fields.Split("\t"[0]).ToArray();
>            var inv = new Invoice();
>            inv.InvoiceNumber = Convert.ToInt32(array[0]);
>            inv.InvoiceDate = Convert.ToDateTime(array[1]);
>            inv.Company = array[2];
>            //etc
>            return inv;
>        }
>        public DateTime InvoiceDate { get; set; }
>        public int InvoiceNumber { get; set; }
>        public decimal Amount { get; set; }
>        public string Company { get; set; }
>    }
Your code could then just be:
IEnumerable<Invoice> invoices = File.ReadAllLines(fileName).Select(s => (Invoice)s);
>//Do whatever

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Previous
Reply
Map
View

Click here to load this message in the networking platform