Thread: new Struct?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    If you think of structs as data blocks in C# and classes as data plus behavior it is much simpler to distinguish between them. You do not need to instantiate structs with new.

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Quote Originally Posted by Bubba View Post
    If you think of structs as data blocks in C# and classes as data plus behavior it is much simpler to distinguish between them. You do not need to instantiate structs with new.
    I would say that it is not a bad idea though to keep a specific syntax. For example you might want to switch a struct with a class later on. Since it is specified that all the links have to be instantiated new is likely to be your most common way to create+initialize a struct. And a good way to re-initialize the struct.

    In a few words the syntax is kind of nice, since it doesn't differ from the most common syntax of instantiating classes. You don't have to worry if it is a class or a struct, but for optimizations for example you can still use a struct, so you could turn a class into a struct later on, depending of course the use.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. casting struct to struct
    By klmdb in forum C Programming
    Replies: 6
    Last Post: 08-14-2010, 02:29 PM
  2. Help me please.
    By yann in forum C Programming
    Replies: 15
    Last Post: 09-29-2009, 09:04 PM
  3. help with structs and malloc!
    By coni in forum C Programming
    Replies: 20
    Last Post: 09-14-2009, 05:38 PM
  4. Replies: 1
    Last Post: 12-03-2008, 03:10 AM
  5. Replies: 10
    Last Post: 05-18-2006, 11:23 PM