locked
about CodeStruct and codeClass RRS feed

  • Question

  • Hi:

    I have an problem about how to use CodeStruct and codeClass. 

    it seems codestruct is much similar to codeclass.  how to distinguish these two, and how to 

    use them in correct way. Thanks a lot.


    • Edited by clementcw Thursday, May 10, 2012 9:36 AM
    Thursday, May 10, 2012 9:21 AM

Answers

  • Hi clementcw,

    The CodeStruct is an object representing a structure in source code. The struct default access type is public. A struct should typically be used for grouping data.
    The CodeClass represents a class in source code. The class default access type is private, and the default mode for inheritance is private. A class should be used for grouping data and methods that operate on that data.
    In short, the convention is to use struct when the purpose is to group data, and use classes when we require data abstraction and, perhaps inheritance.
    More information:

    http://msdn.microsoft.com/en-us/library/20a5aye3

    http://msdn.microsoft.com/en-us/library/envdte.codeclass(v=vs.100).aspx


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by lucy-liu Thursday, May 17, 2012 6:14 AM
    Friday, May 11, 2012 7:12 AM

All replies

  • Hi clementcw,

    The CodeStruct is an object representing a structure in source code. The struct default access type is public. A struct should typically be used for grouping data.
    The CodeClass represents a class in source code. The class default access type is private, and the default mode for inheritance is private. A class should be used for grouping data and methods that operate on that data.
    In short, the convention is to use struct when the purpose is to group data, and use classes when we require data abstraction and, perhaps inheritance.
    More information:

    http://msdn.microsoft.com/en-us/library/20a5aye3

    http://msdn.microsoft.com/en-us/library/envdte.codeclass(v=vs.100).aspx


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by lucy-liu Thursday, May 17, 2012 6:14 AM
    Friday, May 11, 2012 7:12 AM
  • Thanks a lot.
    Friday, May 11, 2012 7:29 AM