Hi guys,
I'm just getting used to OOP and classes etc. I'm really confusing myself.
I have some .csv which contains the column titles (FirstName, SecondName, Address)
I wish to make a class called Person for each row. This would obviously allow me to store Person.FirstName etc.
This bit is fine.
My problem comes because other .csvs have these columns in different order e.g (SecondName, FirstName, Address)
I want to be able to identify which column is "SecondName" e.g Column 1
or 2? and then assign this to the Person class accordingly. I am unsure
of the best way to go about referencing column number and the person
class.
I hope this makes sense and I appreciate all help :)
Many Thanks
Loading
Master BillaPosted Sep 23, 2009, 12:11 PM
I would like to recommend this book
http://books.google.com.sg/books?id=8R451rZJ5o0C&pg=PA166&lpg=PA166&dq=between+class+attributes+and+variables+in+C%23&source=bl&ots=dO12haDLnQ&sig=1Pg_2H021VlW-lkB3PS-6fYUJ0k&hl=en&ei=jki6SpeIEoz66gODpqydAg&sa=X&oi=book_result&ct=result&resnum=6
thank you
Nir BarPosted Sep 23, 2009, 4:18 AM
Your Person class should Derive from DataRow, and have properties that get/set values from the columns of the row
something like (I didn't try to compile it):
Regarding how to populate the table - you can find some ready-made solutions on the web.
Please mark this as answer if it helps you
Nir