Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Structs or Classes

Structs or Classes

Scheduled Pinned Locked Moved C#
question
9 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Heinz_
    wrote on last edited by
    #1

    What's the difference between a struct and a class? why should i use a struct?

    J M T 3 Replies Last reply
    0
    • H Heinz_

      What's the difference between a struct and a class? why should i use a struct?

      J Offline
      J Offline
      Jose Lamas Rios
      wrote on last edited by
      #2

      See Value Type Usage Guidelines[^] -- jlr http://jlamas.blogspot.com/[^]

      1 Reply Last reply
      0
      • H Heinz_

        What's the difference between a struct and a class? why should i use a struct?

        M Offline
        M Offline
        Mystic_Unicorn
        wrote on last edited by
        #3

        struct is value type and class is reference type ... this is the main differece. Martin

        T 1 Reply Last reply
        0
        • M Mystic_Unicorn

          struct is value type and class is reference type ... this is the main differece. Martin

          T Offline
          T Offline
          Tim Smith
          wrote on last edited by
          #4

          WTF? Tim Smith I'm going to patent thought. I have yet to see any prior art.

          B 1 Reply Last reply
          0
          • H Heinz_

            What's the difference between a struct and a class? why should i use a struct?

            T Offline
            T Offline
            Tim Smith
            wrote on last edited by
            #5

            The only difference between a struct and a class is that the members of a class default to "private" while the members of a struct default to "public". Often, for simple data containers, people still use a struct. i.e. struct BOB { int a; int b; }; Tim Smith I'm going to patent thought. I have yet to see any prior art.

            L 1 Reply Last reply
            0
            • T Tim Smith

              WTF? Tim Smith I'm going to patent thought. I have yet to see any prior art.

              B Offline
              B Offline
              big_trev
              wrote on last edited by
              #6

              Sorry Tim, but he is right! :laugh:

              1 Reply Last reply
              0
              • T Tim Smith

                The only difference between a struct and a class is that the members of a class default to "private" while the members of a struct default to "public". Often, for simple data containers, people still use a struct. i.e. struct BOB { int a; int b; }; Tim Smith I'm going to patent thought. I have yet to see any prior art.

                L Offline
                L Offline
                leppie
                wrote on last edited by
                #7

                Tim Smith wrote: The only difference between a struct and a class is that the members of a class default to "private" while the members of a struct default to "public". Wrong forum buddy :laugh: Thats C++ ;P In fact all members in managed constructs are private except enum constant fields :) xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

                T 1 Reply Last reply
                0
                • L leppie

                  Tim Smith wrote: The only difference between a struct and a class is that the members of a class default to "private" while the members of a struct default to "public". Wrong forum buddy :laugh: Thats C++ ;P In fact all members in managed constructs are private except enum constant fields :) xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

                  T Offline
                  T Offline
                  Tim Smith
                  wrote on last edited by
                  #8

                  ROFL... How the **** did I end up here. Sorry guys. LOL. Tim Smith I'm going to patent thought. I have yet to see any prior art.

                  L 1 Reply Last reply
                  0
                  • T Tim Smith

                    ROFL... How the **** did I end up here. Sorry guys. LOL. Tim Smith I'm going to patent thought. I have yet to see any prior art.

                    L Offline
                    L Offline
                    leppie
                    wrote on last edited by
                    #9

                    The same way you break code after a boozing Saturday night :laugh: xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups