Seo Forum

Coding & Programming => ASP Forum => Topic started by: beingchinmay on 01-17-2017, 23:36:21

Title: What are similarities between a class and a structure.
Post by: beingchinmay on 01-17-2017, 23:36:21
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.
Title: Re: What are similarities between a class and a structure.
Post by: wellliving 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.
Title: Re: What are similarities between a class and a structure.
Post by: Tanu S on 04-07-2020, 05:50:35
Hi. Here are some of the basic similarities between a class and a structure I would like to mention:
Class and structures both have constructors, methods, properties, fields, constants, enumerations, events, and event handlers.
Both classes and structures can implement interfaces to use multiple-inheritance in code.
Both can have constructors with parameters.
And, both can have delegates and events.
Title: Re: What are similarities between a class and a structure.
Post by: Lishmalinyjames on 01-26-2021, 02:13:39
Both can have constructors, methods, properties, fields, constants, enumerations, events, and event handlers. Structures and classes can implement the interface. Both of them can have constructors with and without parameter.
Title: Re: What are similarities between a class and a structure.
Post by: saravanan28 on 04-23-2021, 05:38:28
Basically, a class combines the fields and methods(member function which defines actions) into a single unit. A structure is a collection of variables of different data types under a single unit. It is almost similar to a class because both are user-defined data types and both hold a bunch of different data types.
Title: Re: What are similarities between a class and a structure.
Post by: Lishmalinyjames on 05-29-2021, 05:11:32
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.