What are similarities between a class and a structure.

Author Topic: What are similarities between a class and a structure.  (Read 637 times)

Offline beingchinmayTopic starter

  • Trade Count: (0)
  • Jr. Member
  • **
  • Thank You 1
  • Posts: 73
  • Karma: 0
  • Gender: Male
  • I am Chinmay
    • Fat Cutter
Structures and classes are the two most important data structures that are used by programmers to build modular programs by using OOP languages, such as Visual Basic .NET, and Visual C#. The following are some of the similarities between a class and a structure:



 Access specifiers, such as public, private, and protected, are identically used in structures and classes to restrict the access of their data and methods outside their body.
 The access level for class members and struct members, including nested classes and structs, is private by default. Private nested types are not accessible from outside the containing type.
 Both can have constructors, methods, properties, fields, constants, enumerations, events, and event handlers.
 Both structures and classes can implement interfaces to use multiple-inheritance in code.
 Both structures and classes can have constructors with parameter.
 Both structures and classes can have delegates and events.


Offline wellliving

  • Trade Count: (0)
  • Full Member
  • ***
  • Thank You 7
  • Posts: 152
  • Karma: 0
    • Well-living-shop
Re: What are similarities between a class and a structure.
« Reply #1 on: 01-18-2017, 00:26:30 »
Similarities between classes and structures: -
 
Both can have constructors, methods, properties, fields, constants, enumerations, events, and event handlers.
Structures and classes can implement interface.
Both of them can have constructors with and without parameter.
 
Both can have delegates and events.

 

Related Topics

  Subject / Started by Replies Last post
0 Replies
751 Views
Last post 07-20-2012, 01:09:31
by tomjohn
0 Replies
525 Views
Last post 02-13-2016, 00:36:44
by chinmay.sahoo
3 Replies
1702 Views
Last post 12-13-2016, 23:31:12
by saravjeet
0 Replies
605 Views
Last post 09-03-2016, 03:43:26
by beingchinmay
1 Replies
796 Views
Last post 04-25-2017, 03:16:16
by michral86