Creating object of another object

Discussion in 'ASP .Net' started by Maziar Aflatoun, Apr 6, 2005.

  1. Hi everyone,

    I like to do the following,

    1. Create an object that holds the customer general information
    2. Add multiple orders for the customer
    3. Serialize and dump to XML

    I have already taken care of part 1. and know part 3. However, what the best
    of adding multiple orders for 1 customer. Ex.

    Can someone please show me an example of adding multiple orders (Order) to
    the Customer object? Can be 1 or more Orders.


    public class Customer
    {
    public string FirstName;
    public string LastName;

    public Customer()
    {
    }
    }

    public class Order
    {
    public string Name;
    public string Qty;

    public Order()
    {
    }
    }

    Thank you
    Maz.
    Maziar Aflatoun, Apr 6, 2005
    #1
    1. Advertising

  2. Hi Maziar,

    Use an Array of the Order class in the Customer Class. Arrays are implictly
    serializable.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    What You Seek Is What You Get.

    "Maziar Aflatoun" <> wrote in message
    news:...
    > Hi everyone,
    >
    > I like to do the following,
    >
    > 1. Create an object that holds the customer general information
    > 2. Add multiple orders for the customer
    > 3. Serialize and dump to XML
    >
    > I have already taken care of part 1. and know part 3. However, what the
    > best
    > of adding multiple orders for 1 customer. Ex.
    >
    > Can someone please show me an example of adding multiple orders (Order) to
    > the Customer object? Can be 1 or more Orders.
    >
    >
    > public class Customer
    > {
    > public string FirstName;
    > public string LastName;
    >
    > public Customer()
    > {
    > }
    > }
    >
    > public class Order
    > {
    > public string Name;
    > public string Qty;
    >
    > public Order()
    > {
    > }
    > }
    >
    > Thank you
    > Maz.
    >
    >
    >
    Kevin Spencer, Apr 6, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ravi Ambros Wallau
    Replies:
    0
    Views:
    4,075
    Ravi Ambros Wallau
    Jun 1, 2005
  2. Jesper Sahner
    Replies:
    4
    Views:
    485
    Boudewijn Dijkstra
    Jan 18, 2005
  3. Jess
    Replies:
    10
    Views:
    494
    James Kanze
    May 18, 2007
  4. Ravi Ambros Wallau
    Replies:
    0
    Views:
    298
    Ravi Ambros Wallau
    Jun 1, 2005
  5. Erik Wegner

    Exception when creating another object

    Erik Wegner, Aug 12, 2007, in forum: Javascript
    Replies:
    5
    Views:
    107
    Thomas 'PointedEars' Lahn
    Aug 13, 2007
Loading...

Share This Page