C# Object Creation from Datatable

Posted by Jonesy on Stack Overflow See other posts from Stack Overflow or by Jonesy
Published on 2010-03-28T20:58:52Z Indexed on 2010/03/28 21:03 UTC
Read the original article Hit count: 475

Filed under:
|
|
|

Hi Folks,

Im just getting my head round C#. I've been creating classes and objects so say i created a class called Member:

 public class Member
    {
        public int MemberID;
        public string FirstName;
        public string LastName;
        public string UserName;
    }

and i create a new object of that class by doing this:

    Member Billy = new Member();

    Billy.UserName = "Jonesy";
    Billy.FirstName = "Billy";
    Billy.LastName = "Jones";

Thats all fine but what if I've queried a database and gotten back 5 members, can I create objects on the fly? Or what is the best way to store these members in memory?

I've used VB.Net where I would just add them into a datatable. But I've never really done any object-oriented programming before and thought since I'm learning C sharp nows the best time to learn OOP..

Any help most appreciated!

Jonesy

© Stack Overflow or respective owner

Related posts about c#

Related posts about classes