structures vs classes

Discussion in 'ASP .Net Web Services' started by Gian U. Uy, Nov 27, 2003.

  1. Gian U. Uy

    Gian U. Uy Guest

    Hi!

    I'd like to know is what are the prons and cons of using structures (data
    types declared as struct [in c#] or structure [in vb.net]) as against
    classes when passing data from and to a web service?
     
    Gian U. Uy, Nov 27, 2003
    #1
    1. Advertising

  2. Gian U. Uy

    Scott M. Guest

    In general, structures should be used for managing the state (property
    values - data) of something and classes should be used to manage state and
    behavior (methods) of something.

    Because structures are value types, they are managed on the stack as opposed
    to classes, which are reference types and therefore managed on the heap.
    Since the stack is a more limited storage area than the heap, thinner
    objects are generally placed there and more complex objects (classes) go on
    the heap, which is a bigger storage area.

    Also, with value types (structures), you can easily pass them ByVal whereas
    with a reference type (classes), you pass ByRef.




    "Gian U. Uy" <> wrote in message
    news:...
    > Hi!
    >
    > I'd like to know is what are the prons and cons of using structures (data
    > types declared as struct [in c#] or structure [in vb.net]) as against
    > classes when passing data from and to a web service?
    >
    >
     
    Scott M., Nov 29, 2003
    #2
    1. Advertising

  3. Hi,

    There is no such difference from a Web Service point of view, since the data
    sent over the web service is in XML format which is independent of being
    generated from a class or struct.'


    Regards,
    Akila
    [MVP]
     
    Saurabh Nandu, Nov 29, 2003
    #3
  4. Gian U. Uy

    Gian U. Uy Guest

    Thanks. This exactly answers my inquiry

    "Saurabh Nandu" <> wrote in message
    news:ucCA#...
    > Hi,
    >
    > There is no such difference from a Web Service point of view, since the

    data
    > sent over the web service is in XML format which is independent of being
    > generated from a class or struct.'
    >
    >
    > Regards,
    > Akila
    > [MVP]
    >
    >
     
    Gian U. Uy, Nov 29, 2003
    #4
    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. Replies:
    6
    Views:
    6,809
    Malcolm
    Aug 16, 2003
  2. tweak
    Replies:
    14
    Views:
    2,814
    Eric Sosman
    Jun 11, 2004
  3. Joel Forrest Moxley

    nested data structures in classes

    Joel Forrest Moxley, Aug 24, 2003, in forum: Python
    Replies:
    2
    Views:
    394
  4. Joel
    Replies:
    1
    Views:
    318
    Tyler Eaves
    Aug 24, 2003
  5. Alfonso Morra
    Replies:
    11
    Views:
    741
    Emmanuel Delahaye
    Sep 24, 2005
Loading...

Share This Page